OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <set> | 5 #include <set> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/metrics/histogram_base.h" | 12 #include "base/metrics/histogram_base.h" |
13 #include "base/metrics/histogram_samples.h" | 13 #include "base/metrics/histogram_samples.h" |
14 #include "base/metrics/statistics_recorder.h" | 14 #include "base/metrics/statistics_recorder.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
19 #include "chrome/browser/prefs/pref_hash_store.h" | 20 #include "chrome/browser/prefs/pref_hash_store.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/profiles/profile_impl.h" | |
22 #include "chrome/browser/profiles/profile_info_cache.h" | 22 #include "chrome/browser/profiles/profile_info_cache.h" |
23 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
24 #include "chrome/browser/profiles/profiles_state.h" | 24 #include "chrome/browser/profiles/profiles_state.h" |
25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
26 #include "chrome/test/base/in_process_browser_test.h" | 26 #include "chrome/test/base/in_process_browser_test.h" |
27 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // An observer that returns back to test code after a new profile is | 31 // An observer that returns back to test code after a new profile is |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 const base::DictionaryValue* hashes = | 135 const base::DictionaryValue* hashes = |
136 g_browser_process->local_state()->GetDictionary( | 136 g_browser_process->local_state()->GetDictionary( |
137 prefs::kProfilePreferenceHashes); | 137 prefs::kProfilePreferenceHashes); |
138 | 138 |
139 // 3 is for hash_of_hashes, default profile, and new profile. | 139 // 3 is for hash_of_hashes, default profile, and new profile. |
140 ASSERT_EQ(3U, hashes->size()); | 140 ASSERT_EQ(3U, hashes->size()); |
141 | 141 |
142 // One of the two profiles should not have been loaded. Reset its hash store. | 142 // One of the two profiles should not have been loaded. Reset its hash store. |
143 const base::FilePath unloaded_profile_path = GetUnloadedProfilePath(); | 143 const base::FilePath unloaded_profile_path = GetUnloadedProfilePath(); |
144 ProfileImpl::ResetPrefHashStore(unloaded_profile_path); | 144 chrome_prefs::ResetPrefHashStore(unloaded_profile_path); |
145 | 145 |
146 // One of the profile hash collections should be gone. | 146 // One of the profile hash collections should be gone. |
147 ASSERT_EQ(2U, hashes->size()); | 147 ASSERT_EQ(2U, hashes->size()); |
148 | 148 |
149 // No profile should have gone through the unloaded profile initialization in | 149 // No profile should have gone through the unloaded profile initialization in |
150 // this phase as both profiles were already initialized at the beginning of | 150 // this phase as both profiles were already initialized at the beginning of |
151 // this phase (resetting the unloaded profile's PrefHashStore should only | 151 // this phase (resetting the unloaded profile's PrefHashStore should only |
152 // force initialization in the next phase's startup). | 152 // force initialization in the next phase's startup). |
153 EXPECT_EQ( | 153 EXPECT_EQ( |
154 0, GetTrackedPrefHistogramCount( | 154 0, GetTrackedPrefHistogramCount( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 0, GetTrackedPrefHistogramCount( | 223 0, GetTrackedPrefHistogramCount( |
224 "Settings.TrackedPreferenceTrustedInitialized", true)); | 224 "Settings.TrackedPreferenceTrustedInitialized", true)); |
225 EXPECT_EQ( | 225 EXPECT_EQ( |
226 0, GetTrackedPrefHistogramCount( | 226 0, GetTrackedPrefHistogramCount( |
227 "Settings.TrackedPreferenceMigrated", true)); | 227 "Settings.TrackedPreferenceMigrated", true)); |
228 EXPECT_EQ( | 228 EXPECT_EQ( |
229 initial_unchanged_count * 2, | 229 initial_unchanged_count * 2, |
230 GetTrackedPrefHistogramCount("Settings.TrackedPreferenceUnchanged", | 230 GetTrackedPrefHistogramCount("Settings.TrackedPreferenceUnchanged", |
231 false)); | 231 false)); |
232 } | 232 } |
OLD | NEW |