Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/browser/metrics/field_trial_synchronizer.cc

Issue 2950173003: Support add-on 'field trial' records. (Closed)
Patch Set: addressed review comments by asvitkine Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/metrics/persistent_system_profile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/metrics/field_trial_synchronizer.h" 5 #include "chrome/browser/metrics/field_trial_synchronizer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "chrome/common/renderer_configuration.mojom.h" 10 #include "chrome/common/renderer_configuration.mojom.h"
11 #include "components/metrics/persistent_system_profile.h"
11 #include "components/variations/variations_util.h" 12 #include "components/variations/variations_util.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
14 15
15 using content::BrowserThread; 16 using content::BrowserThread;
16 17
17 namespace { 18 namespace {
18 19
19 // This singleton instance should be constructed during the single threaded 20 // This singleton instance should be constructed during the single threaded
20 // portion of main(). It initializes globals to provide support for all future 21 // portion of main(). It initializes globals to provide support for all future
(...skipping 11 matching lines...) Expand all
32 variations::SetVariationListCrashKeys(); 33 variations::SetVariationListCrashKeys();
33 } 34 }
34 35
35 void FieldTrialSynchronizer::NotifyAllRenderers( 36 void FieldTrialSynchronizer::NotifyAllRenderers(
36 const std::string& field_trial_name, 37 const std::string& field_trial_name,
37 const std::string& group_name) { 38 const std::string& group_name) {
38 // To iterate over RenderProcessHosts, or to send messages to the hosts, we 39 // To iterate over RenderProcessHosts, or to send messages to the hosts, we
39 // need to be on the UI thread. 40 // need to be on the UI thread.
40 DCHECK_CURRENTLY_ON(BrowserThread::UI); 41 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41 42
43 // Note this in the persistent profile as it will take a while for a new
44 // "complete" profile to be genereated.
45 metrics::GlobalPersistentSystemProfile::GetInstance()->AddFieldTrial(
46 field_trial_name, group_name);
47
42 for (content::RenderProcessHost::iterator it( 48 for (content::RenderProcessHost::iterator it(
43 content::RenderProcessHost::AllHostsIterator()); 49 content::RenderProcessHost::AllHostsIterator());
44 !it.IsAtEnd(); it.Advance()) { 50 !it.IsAtEnd(); it.Advance()) {
45 IPC::ChannelProxy* channel = it.GetCurrentValue()->GetChannel(); 51 IPC::ChannelProxy* channel = it.GetCurrentValue()->GetChannel();
46 // channel might be null in tests. 52 // channel might be null in tests.
47 if (channel) { 53 if (channel) {
48 chrome::mojom::RendererConfigurationAssociatedPtr renderer_configuration; 54 chrome::mojom::RendererConfigurationAssociatedPtr renderer_configuration;
49 channel->GetRemoteAssociatedInterface(&renderer_configuration); 55 channel->GetRemoteAssociatedInterface(&renderer_configuration);
50 renderer_configuration->SetFieldTrialGroup(field_trial_name, group_name); 56 renderer_configuration->SetFieldTrialGroup(field_trial_name, group_name);
51 } 57 }
52 } 58 }
53 } 59 }
54 60
55 void FieldTrialSynchronizer::OnFieldTrialGroupFinalized( 61 void FieldTrialSynchronizer::OnFieldTrialGroupFinalized(
56 const std::string& field_trial_name, 62 const std::string& field_trial_name,
57 const std::string& group_name) { 63 const std::string& group_name) {
58 BrowserThread::PostTask( 64 BrowserThread::PostTask(
59 BrowserThread::UI, FROM_HERE, 65 BrowserThread::UI, FROM_HERE,
60 base::BindOnce(&FieldTrialSynchronizer::NotifyAllRenderers, this, 66 base::BindOnce(&FieldTrialSynchronizer::NotifyAllRenderers, this,
61 field_trial_name, group_name)); 67 field_trial_name, group_name));
62 variations::SetVariationListCrashKeys(); 68 variations::SetVariationListCrashKeys();
63 } 69 }
64 70
65 FieldTrialSynchronizer::~FieldTrialSynchronizer() { 71 FieldTrialSynchronizer::~FieldTrialSynchronizer() {
66 base::FieldTrialList::RemoveObserver(this); 72 base::FieldTrialList::RemoveObserver(this);
67 g_field_trial_synchronizer = NULL; 73 g_field_trial_synchronizer = NULL;
68 } 74 }
OLDNEW
« no previous file with comments | « no previous file | components/metrics/persistent_system_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698