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

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

Issue 2642263002: Convert ChromeViewMsg_SetFieldTrialGroup to use mojo. (Closed)
Patch Set: Convert ChromeViewMsg_SetFieldTrialGroup to use mojo. Created 3 years, 11 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
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/render_messages.h" 10 #include "chrome/common/renderer_configuration.mojom.h"
11 #include "components/variations/variations_util.h" 11 #include "components/variations/variations_util.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
14 14
15 using content::BrowserThread; 15 using content::BrowserThread;
16 16
17 namespace { 17 namespace {
18 18
19 // This singleton instance should be constructed during the single threaded 19 // This singleton instance should be constructed during the single threaded
20 // portion of main(). It initializes globals to provide support for all future 20 // portion of main(). It initializes globals to provide support for all future
(...skipping 14 matching lines...) Expand all
35 void FieldTrialSynchronizer::NotifyAllRenderers( 35 void FieldTrialSynchronizer::NotifyAllRenderers(
36 const std::string& field_trial_name, 36 const std::string& field_trial_name,
37 const std::string& group_name) { 37 const std::string& group_name) {
38 // To iterate over RenderProcessHosts, or to send messages to the hosts, we 38 // To iterate over RenderProcessHosts, or to send messages to the hosts, we
39 // need to be on the UI thread. 39 // need to be on the UI thread.
40 DCHECK_CURRENTLY_ON(BrowserThread::UI); 40 DCHECK_CURRENTLY_ON(BrowserThread::UI);
41 41
42 for (content::RenderProcessHost::iterator it( 42 for (content::RenderProcessHost::iterator it(
43 content::RenderProcessHost::AllHostsIterator()); 43 content::RenderProcessHost::AllHostsIterator());
44 !it.IsAtEnd(); it.Advance()) { 44 !it.IsAtEnd(); it.Advance()) {
45 it.GetCurrentValue()->Send(new ChromeViewMsg_SetFieldTrialGroup( 45 IPC::ChannelProxy* channel = it.GetCurrentValue()->GetChannel();
46 field_trial_name, group_name)); 46 // channel might be NULL in tests.
47 if (channel) {
48 chrome::mojom::RendererConfigurationAssociatedPtr renderer_configuration;
49 channel->GetRemoteAssociatedInterface(&renderer_configuration);
50 renderer_configuration->SetFieldTrialGroup(field_trial_name, group_name);
51 }
47 } 52 }
48 } 53 }
49 54
50 void FieldTrialSynchronizer::OnFieldTrialGroupFinalized( 55 void FieldTrialSynchronizer::OnFieldTrialGroupFinalized(
51 const std::string& field_trial_name, 56 const std::string& field_trial_name,
52 const std::string& group_name) { 57 const std::string& group_name) {
53 BrowserThread::PostTask( 58 BrowserThread::PostTask(
54 BrowserThread::UI, FROM_HERE, 59 BrowserThread::UI, FROM_HERE,
55 base::Bind(&FieldTrialSynchronizer::NotifyAllRenderers, 60 base::Bind(&FieldTrialSynchronizer::NotifyAllRenderers,
56 this, 61 this,
57 field_trial_name, 62 field_trial_name,
58 group_name)); 63 group_name));
59 variations::SetVariationListCrashKeys(); 64 variations::SetVariationListCrashKeys();
60 } 65 }
61 66
62 FieldTrialSynchronizer::~FieldTrialSynchronizer() { 67 FieldTrialSynchronizer::~FieldTrialSynchronizer() {
63 base::FieldTrialList::RemoveObserver(this); 68 base::FieldTrialList::RemoveObserver(this);
64 g_field_trial_synchronizer = NULL; 69 g_field_trial_synchronizer = NULL;
65 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698