OLD | NEW |
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/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 // Check that the sender's PID doesn't change between messages. We expect | 43 // Check that the sender's PID doesn't change between messages. We expect |
44 // these IPCs to always be delivered from the same browser process, whose pid | 44 // these IPCs to always be delivered from the same browser process, whose pid |
45 // should not change. | 45 // should not change. |
46 // TODO(asvitkine): Remove this after http://crbug.com/359406 is fixed. | 46 // TODO(asvitkine): Remove this after http://crbug.com/359406 is fixed. |
47 static base::ProcessId sender_pid = base::Process::Current().Pid(); | 47 static base::ProcessId sender_pid = base::Process::Current().Pid(); |
48 for (content::RenderProcessHost::iterator it( | 48 for (content::RenderProcessHost::iterator it( |
49 content::RenderProcessHost::AllHostsIterator()); | 49 content::RenderProcessHost::AllHostsIterator()); |
50 !it.IsAtEnd(); it.Advance()) { | 50 !it.IsAtEnd(); it.Advance()) { |
51 it.GetCurrentValue()->Send(new ChromeViewMsg_SetFieldTrialGroup( | 51 it.GetCurrentValue()->Send(new ChromeViewMsg_SetFieldTrialGroup( |
52 field_trial_name, group_name, sender_pid)); | 52 field_trial_name, group_name, sender_pid, |
| 53 base::FieldTrialList::GetDebugToken())); |
53 } | 54 } |
54 } | 55 } |
55 | 56 |
56 void FieldTrialSynchronizer::OnFieldTrialGroupFinalized( | 57 void FieldTrialSynchronizer::OnFieldTrialGroupFinalized( |
57 const std::string& field_trial_name, | 58 const std::string& field_trial_name, |
58 const std::string& group_name) { | 59 const std::string& group_name) { |
59 // TODO(asvitkine): Remove these CHECKs once http://crbug.com/359406 is fixed. | 60 // TODO(asvitkine): Remove these CHECKs once http://crbug.com/359406 is fixed. |
60 CHECK(!field_trial_name.empty() && !group_name.empty()); | 61 CHECK(!field_trial_name.empty() && !group_name.empty()); |
61 CHECK_EQ(group_name, base::FieldTrialList::FindFullName(field_trial_name)) | 62 CHECK_EQ(group_name, base::FieldTrialList::FindFullName(field_trial_name)) |
62 << field_trial_name << ":" << group_name << "=>" | 63 << field_trial_name << ":" << group_name << "=>" |
63 << base::FieldTrialList::FindFullName(field_trial_name); | 64 << base::FieldTrialList::FindFullName(field_trial_name); |
64 BrowserThread::PostTask( | 65 BrowserThread::PostTask( |
65 BrowserThread::UI, FROM_HERE, | 66 BrowserThread::UI, FROM_HERE, |
66 base::Bind(&FieldTrialSynchronizer::NotifyAllRenderers, | 67 base::Bind(&FieldTrialSynchronizer::NotifyAllRenderers, |
67 this, | 68 this, |
68 field_trial_name, | 69 field_trial_name, |
69 group_name)); | 70 group_name)); |
70 variations::SetVariationListCrashKeys(); | 71 variations::SetVariationListCrashKeys(); |
71 } | 72 } |
72 | 73 |
73 FieldTrialSynchronizer::~FieldTrialSynchronizer() { | 74 FieldTrialSynchronizer::~FieldTrialSynchronizer() { |
74 base::FieldTrialList::RemoveObserver(this); | 75 base::FieldTrialList::RemoveObserver(this); |
75 g_field_trial_synchronizer = NULL; | 76 g_field_trial_synchronizer = NULL; |
76 } | 77 } |
OLD | NEW |