0
Commit Graph

12 Commits

Author SHA1 Message Date
Dan Harrington
42d5c83e1a Revert^2 "Add code supporting new field-trial-internals page"
This reverts commit 269aa9d493.

Reason for revert: including fix for test

Original change's description:
> Revert "Add code supporting new field-trial-internals page"
>
> This reverts commit b8e462bc4b.
>
> Reason for revert: This CL is likely the cause of test failure CfmBrowserServiceTest.GetVariationsData on https://ci.chromium.org/ui/p/chromium/builders/ci/linux-cfm-rel starting from https://ci.chromium.org/ui/b/8763776059209925809. Error message: Expected equality of these values:
>   field_trial_states
>     Which is: "*Baz/Qux/Foo/Bar/"
>   states
>     Which is: "*Baz/Qux/Foo/Bar"
>
> Original change's description:
> > Add code supporting new field-trial-internals page
> >
> > This CL lays the groundwork for a future
> > field-trial-internals page, with the following changes:
> >
> > * Update base::FieldTrial to include an 'overridden' flag,
> >   which is used to change variation group hashes so
> >   overridden trial hashes are distinct.
> > * I pulled out code to build field trial strings
> >   into AppendFieldTrialGroupToString, to be reused. In some places, we
> >   were adding a trailing '/', and other places we weren't. Now we omit
> >   the trailing slash everywhere. We can still parse the string
> >   with or without the trailing slash.
> >
> > See go/field-trial-internals-dd for more information.
> >
> > Bug: b:284986126
> > Change-Id: I58b86c558cd7973bb6a493322353b52ebf9f619f
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4620752
> > Reviewed-by: Richard (Torne) Coles <torne@chromium.org>
> > Reviewed-by: Matt Menke <mmenke@chromium.org>
> > Reviewed-by: Mike Dougherty <michaeldo@chromium.org>
> > Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
> > Commit-Queue: Dan H <harringtond@chromium.org>
> > Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
> > Reviewed-by: Erik Chen <erikchen@chromium.org>
> > Reviewed-by: Luc Nguyen <lucnguyen@google.com>
> > Cr-Commit-Position: refs/heads/main@{#1227624}
>
> Bug: b:284986126
> Change-Id: I18f84ccf307f6265da24b3603b82344e1bf42c20
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5052200
> Owners-Override: Maggie Cai <mxcai@chromium.org>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Maggie Cai <mxcai@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1227726}

Bug: b:284986126
Change-Id: Id00f514233c08aa439caaa7f4d6bdaa6c5fc38d5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5055166
Reviewed-by: Luc Nguyen <lucnguyen@google.com>
Reviewed-by: Erik Chen <erikchen@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: Paul Moy <pmoy@chromium.org>
Reviewed-by: Richard (Torne) Coles <torne@chromium.org>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1229416}
2023-11-27 18:10:16 +00:00
Maggie Cai
269aa9d493 Revert "Add code supporting new field-trial-internals page"
This reverts commit b8e462bc4b.

Reason for revert: This CL is likely the cause of test failure CfmBrowserServiceTest.GetVariationsData on https://ci.chromium.org/ui/p/chromium/builders/ci/linux-cfm-rel starting from https://ci.chromium.org/ui/b/8763776059209925809. Error message: Expected equality of these values:
  field_trial_states
    Which is: "*Baz/Qux/Foo/Bar/"
  states
    Which is: "*Baz/Qux/Foo/Bar"

Original change's description:
> Add code supporting new field-trial-internals page
>
> This CL lays the groundwork for a future
> field-trial-internals page, with the following changes:
>
> * Update base::FieldTrial to include an 'overridden' flag,
>   which is used to change variation group hashes so
>   overridden trial hashes are distinct.
> * I pulled out code to build field trial strings
>   into AppendFieldTrialGroupToString, to be reused. In some places, we
>   were adding a trailing '/', and other places we weren't. Now we omit
>   the trailing slash everywhere. We can still parse the string
>   with or without the trailing slash.
>
> See go/field-trial-internals-dd for more information.
>
> Bug: b:284986126
> Change-Id: I58b86c558cd7973bb6a493322353b52ebf9f619f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4620752
> Reviewed-by: Richard (Torne) Coles <torne@chromium.org>
> Reviewed-by: Matt Menke <mmenke@chromium.org>
> Reviewed-by: Mike Dougherty <michaeldo@chromium.org>
> Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
> Commit-Queue: Dan H <harringtond@chromium.org>
> Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
> Reviewed-by: Erik Chen <erikchen@chromium.org>
> Reviewed-by: Luc Nguyen <lucnguyen@google.com>
> Cr-Commit-Position: refs/heads/main@{#1227624}

Bug: b:284986126
Change-Id: I18f84ccf307f6265da24b3603b82344e1bf42c20
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5052200
Owners-Override: Maggie Cai <mxcai@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1227726}
2023-11-22 01:16:02 +00:00
Dan Harrington
b8e462bc4b Add code supporting new field-trial-internals page
This CL lays the groundwork for a future
field-trial-internals page, with the following changes:

* Update base::FieldTrial to include an 'overridden' flag,
  which is used to change variation group hashes so
  overridden trial hashes are distinct.
* I pulled out code to build field trial strings
  into AppendFieldTrialGroupToString, to be reused. In some places, we
  were adding a trailing '/', and other places we weren't. Now we omit
  the trailing slash everywhere. We can still parse the string
  with or without the trailing slash.

See go/field-trial-internals-dd for more information.

Bug: b:284986126
Change-Id: I58b86c558cd7973bb6a493322353b52ebf9f619f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4620752
Reviewed-by: Richard (Torne) Coles <torne@chromium.org>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Reviewed-by: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Erik Chen <erikchen@chromium.org>
Reviewed-by: Luc Nguyen <lucnguyen@google.com>
Cr-Commit-Position: refs/heads/main@{#1227624}
2023-11-21 22:22:46 +00:00
Avi Drissman
4e1b7bc33d Update copyright headers in content/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c34.

No-Try: true
No-Presubmit: true
Bug: 1098010
Change-Id: I8c0f009d16350271f07d8e5e561085822cc9dd27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3895935
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047456}
2022-09-15 14:03:50 +00:00
Peter Boström
1d6a095400 Remove unused "base/macros.h" in content/
Removes `#include "base/macros.h"` from files in content/ that do not
contain `ignore_result(`.

Bug: 1010217
No-Try: true
Change-Id: I887403408704241047e3bd66e953ff7df195368b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3274993
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#940781}
2021-11-11 16:07:03 +00:00
Peter Boström
9b036533b6 Remove DISALLOW_* macros from content/
This inlines all remaining DISALLOW_* macros in content/. This is done
manually (vim regex + manually finding insertion position).

IWYU cleanup is left as a separate pass that is easier when these macros
go away.

Bug: 1010217
Change-Id: I8b5ea6dd9f8a3f584cf3eef82634017a38b15be8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3193883
Commit-Queue: Peter Boström <pbos@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Peter Boström <pbos@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#936160}
2021-10-28 23:37:28 +00:00
Francois Doray
da23db5bc2 Reland "[base] Stop using ObserverListThreadSafe::NotifySynchronously in FieldTrialList."
== Changes since original CL ==

This CL registers ChildProcessFieldTrialSyncer as a FieldTrialList
observer instead of ChildThreadImpl and it makes
ChildProcessFieldTrialSyncer a leaky singleton. This eliminates
lifetime issues.

An alternative would have been to remove ChildThreadImpl from the list
of FieldTrialList observers upon destruction. We decided not to do that
because it would have required extra synchronization.

Diff: https://crrev.com/c/2867567/1..16

== Original description ==

This CL removes usage of ObserverListThreadSafe::NotifySynchronously
in FieldTrialList, to support the removal of this method in a
separate CL.

Currently, FieldTrialList uses
ObserverListThreadSafe::NotifySynchronously to notify observers when a
group is selected for a field trial. This method dispatches synchronous
notifications to observers which were registered on the current
sequence, and uses PostTask to notify other observers asynchronously.
Through code inspection, we found that all implementations of
FieldTrialList::Observer::OnFieldTrialGroupFinalized are
thread-safe. Therefore, they can always be notified synchronously,
no matter which sequence they were registered from.

This CL makes these changes:

- Observers are stored in a lock-protected std::vector instead of
  in an ObserverListThreadSafe.
- To notify observers, the list of observers is copied to a local
  variable while holding the lock. Then, after releasing the
  lock, all observers in the local list are notified.
- In the scope where observers are notified, an atomic variable is
  incremented. The RemoveObserver method checks that the variable is
  equal to zero. This ensures that no observer is removed while
  dispatching notifications (which could cause a use-after-free).

For reference, the implementations of
FieldTrialList::Observer::OnFieldTrialGroupFinalized are:

base/android/field_trial_list.cc:
  LOG(INFO) is thread-safe

base/metrics/field_trial_unittest.cc:
  The test is single-threaded.

components/variations/child_process_field_trial_syncer_unittest.cc:
  The test is single-threaded.

components/variations/variations_crash_keys.cc:
  The observer checks whether it runs on the UI thread and
  forwards the notification to the UI thread if it's not the case.

components/variations/variations_ids_provider.cc:
  The observer uses a lock.

content/browser/field_trial_synchronizer.cc:
  The observer checks whether it runs on the UI thread and
  forwards the notification to the UI thread if it's not the case.

content/browser/net/network_field_trial_browsertest.cc
  RunLoop::Quit() is thread-safe.

content/child/child_thread_impl.cc
  A mojo::SharedRemote is thread-safe.

Bug: 1193750
Change-Id: I8351a2cbbce4d5deaafbe2aa75f902e6da822d53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2867567
Commit-Queue: François Doray <fdoray@chromium.org>
Auto-Submit: François Doray <fdoray@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880105}
2021-05-06 22:34:36 +00:00
Francois Doray
9985b63991 Revert "[base] Stop using ObserverListThreadSafe::NotifySynchronously in FieldTrialList."
This reverts commit c08a6d22da.

Reason: crbug.com/1201501

Bug: 1193750, 1201501
Change-Id: Ia7cddfb32eb3683b55e820190455cef9d164d28d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2867606
Auto-Submit: François Doray <fdoray@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#879349}
2021-05-05 14:45:37 +00:00
Francois Doray
c08a6d22da [base] Stop using ObserverListThreadSafe::NotifySynchronously in FieldTrialList.
This CL removes usage of ObserverListThreadSafe::NotifySynchronously
in FieldTrialList, to support the removal of this method in a
separate CL.

Currently, FieldTrialList uses
ObserverListThreadSafe::NotifySynchronously to notify observers when a
group is selected for a field trial. This method dispatches synchronous
notifications to observers which were registered on the current
sequence, and uses PostTask to notify other observers asynchronously.
Through code inspection, we found that all implementations of
FieldTrialList::Observer::OnFieldTrialGroupFinalized are
thread-safe. Therefore, they can always be notified synchronously,
no matter which sequence they were registered from.

This CL makes these changes:

- Observers are stored in a lock-protected std::vector instead of
  in an ObserverListThreadSafe.
- To notify observers, the list of observers is copied to a local
  variable while holding the lock. Then, after releasing the
  lock, all observers in the local list are notified.
- In the scope where observers are notified, an atomic variable is
  incremented. The RemoveObserver method checks that the variable is
  equal to zero. This ensures that no observer is removed while
  dispatching notifications (which could cause a use-after-free).

For reference, the implementations of
FieldTrialList::Observer::OnFieldTrialGroupFinalized are:

base/android/field_trial_list.cc:
  LOG(INFO) is thread-safe

base/metrics/field_trial_unittest.cc:
  The test is single-threaded.

components/variations/child_process_field_trial_syncer_unittest.cc:
  The test is single-threaded.

components/variations/variations_crash_keys.cc:
  The observer checks whether it runs on the UI thread and
  forwards the notification to the UI thread if it's not the case.

components/variations/variations_ids_provider.cc:
  The observer uses a lock.

content/browser/field_trial_synchronizer.cc:
  The observer checks whether it runs on the UI thread and
  forwards the notification to the UI thread if it's not the case.

content/browser/net/network_field_trial_browsertest.cc
  RunLoop::Quit() is thread-safe.

content/child/child_thread_impl.cc
  A mojo::SharedRemote is thread-safe.

Bug: 1193750
Change-Id: I0144d3262fca360fbd2a48580e322428510f91d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2785140
Auto-Submit: François Doray <fdoray@chromium.org>
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#870762}
2021-04-08 23:38:17 +00:00
Ben Goldberger
72533cd919 Rename 'variations_http_header_provider' to 'variations_ids_provider'.
Follow up to https://chromium-review.googlesource.com/c/chromium/src/+/2196817

Bug: 1079458
Change-Id: I22dc45f0399b3978e494ab20b66ef5126ccea580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231906
Auto-Submit: Ben Goldberger <benwgold@google.com>
Reviewed-by: Theresa  <twellington@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Commit-Queue: Yaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790414}
2020-07-21 16:11:38 +00:00
Alex Clarke
3ebd977605 Move code to send the variations header to the renderer into content
This allows it to be shared by Chrome, WebLayer and WebView. For Chrome
this functionality is tested by VariationsHttpHeadersBrowserTest.

To support this a VariationsClient has been added, with an accessor on
BrowserContext, which allows the variations code to tell if the user is
signed in (some of the variations header logic needs to know this).

Bug: 1025612
Change-Id: Ibb5a0dd54e23a3536de4c0fb84624173a6974262
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1967245
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745404}
2020-02-28 10:50:27 +00:00
Alex Clarke
9fc39b9b8a Move FieldTrialSynchronizer into content so it can be used by WebLayer
and other embedders.

There doesn't appear to be any existing tests for this functionality
and I'm not sure how to easily test it.

Bug: 1025612
Change-Id: I81354ff16a6bb9c9bc3a9ada99018ad1e2c82031
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1959034
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737363}
2020-01-31 17:29:47 +00:00