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

Side by Side Diff: chrome/test/base/testing_pref_service.cc

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix double registration in Chrome Frame test. Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/testing_pref_service.h ('k') | chrome/test/reliability/page_load_test.cc » ('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/test/base/testing_pref_service.h" 5 #include "chrome/test/base/testing_pref_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h"
8 #include "base/prefs/default_pref_store.h" 9 #include "base/prefs/default_pref_store.h"
9 #include "chrome/browser/prefs/browser_prefs.h" 10 #include "chrome/browser/prefs/browser_prefs.h"
10 #include "chrome/browser/prefs/pref_notifier_impl.h" 11 #include "chrome/browser/prefs/pref_notifier_impl.h"
12 #include "chrome/browser/prefs/pref_registry_simple.h"
11 #include "chrome/browser/prefs/pref_value_store.h" 13 #include "chrome/browser/prefs/pref_value_store.h"
12 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 namespace { 17 namespace {
16 18
17 // Do-nothing implementation for TestingPrefService. 19 // Do-nothing implementation for TestingPrefService.
18 void HandleReadError(PersistentPrefStore::PrefReadError error) { 20 void HandleReadError(PersistentPrefStore::PrefReadError error) {
19 } 21 }
20 22
21 } // namespace 23 } // namespace
22 24
23 template<> 25 template<>
24 TestingPrefServiceBase<PrefServiceSimple>::TestingPrefServiceBase( 26 TestingPrefServiceBase<PrefService>::TestingPrefServiceBase(
25 TestingPrefStore* managed_prefs, 27 TestingPrefStore* managed_prefs,
26 TestingPrefStore* user_prefs, 28 TestingPrefStore* user_prefs,
27 TestingPrefStore* recommended_prefs, 29 TestingPrefStore* recommended_prefs,
28 DefaultPrefStore* default_store, 30 PrefRegistry* pref_registry,
29 PrefNotifierImpl* pref_notifier) 31 PrefNotifierImpl* pref_notifier)
30 : PrefServiceSimple(pref_notifier, 32 : PrefService(pref_notifier,
31 new PrefValueStore( 33 new PrefValueStore(
32 managed_prefs, 34 managed_prefs,
33 NULL, 35 NULL,
34 NULL, 36 NULL,
35 user_prefs, 37 user_prefs,
36 recommended_prefs, 38 recommended_prefs,
37 default_store, 39 pref_registry->defaults(),
38 pref_notifier), 40 pref_notifier),
39 user_prefs, 41 user_prefs,
40 default_store, 42 pref_registry,
41 base::Bind(&HandleReadError), 43 base::Bind(&HandleReadError),
42 false), 44 false),
43 managed_prefs_(managed_prefs), 45 managed_prefs_(managed_prefs),
44 user_prefs_(user_prefs), 46 user_prefs_(user_prefs),
45 recommended_prefs_(recommended_prefs) { 47 recommended_prefs_(recommended_prefs) {
46 } 48 }
47 49
48 template<> 50 template<>
49 TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase( 51 TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase(
50 TestingPrefStore* managed_prefs, 52 TestingPrefStore* managed_prefs,
51 TestingPrefStore* user_prefs, 53 TestingPrefStore* user_prefs,
52 TestingPrefStore* recommended_prefs, 54 TestingPrefStore* recommended_prefs,
53 DefaultPrefStore* default_store, 55 PrefRegistry* pref_registry,
54 PrefNotifierImpl* pref_notifier) 56 PrefNotifierImpl* pref_notifier)
55 : PrefServiceSyncable(pref_notifier, 57 : PrefServiceSyncable(pref_notifier,
56 new PrefValueStore( 58 new PrefValueStore(
57 managed_prefs, 59 managed_prefs,
58 NULL, 60 NULL,
59 NULL, 61 NULL,
60 user_prefs, 62 user_prefs,
61 recommended_prefs, 63 recommended_prefs,
62 default_store, 64 pref_registry->defaults(),
63 pref_notifier), 65 pref_notifier),
64 user_prefs, 66 user_prefs,
65 default_store, 67 pref_registry,
66 base::Bind(&HandleReadError), 68 base::Bind(&HandleReadError),
67 false), 69 false),
68 managed_prefs_(managed_prefs), 70 managed_prefs_(managed_prefs),
69 user_prefs_(user_prefs), 71 user_prefs_(user_prefs),
70 recommended_prefs_(recommended_prefs) { 72 recommended_prefs_(recommended_prefs) {
71 } 73 }
72 74
73 TestingPrefServiceSimple::TestingPrefServiceSimple() 75 TestingPrefServiceSimple::TestingPrefServiceSimple()
74 : TestingPrefServiceBase<PrefServiceSimple>(new TestingPrefStore(), 76 : TestingPrefServiceBase<PrefService>(
75 new TestingPrefStore(), 77 new TestingPrefStore(),
76 new TestingPrefStore(), 78 new TestingPrefStore(),
77 new DefaultPrefStore(), 79 new TestingPrefStore(),
78 new PrefNotifierImpl()) { 80 new PrefRegistrySimple(),
81 new PrefNotifierImpl()) {
79 } 82 }
80 83
81 TestingPrefServiceSimple::~TestingPrefServiceSimple() { 84 TestingPrefServiceSimple::~TestingPrefServiceSimple() {
82 } 85 }
83 86
87 PrefRegistrySimple* TestingPrefServiceSimple::registry() {
88 return static_cast<PrefRegistrySimple*>(DeprecatedGetPrefRegistry());
89 }
90
91 // TODO(joi): Switch to PrefRegistrySyncable once available.
84 TestingPrefServiceSyncable::TestingPrefServiceSyncable() 92 TestingPrefServiceSyncable::TestingPrefServiceSyncable()
85 : TestingPrefServiceBase<PrefServiceSyncable>(new TestingPrefStore(), 93 : TestingPrefServiceBase<PrefServiceSyncable>(
86 new TestingPrefStore(), 94 new TestingPrefStore(),
87 new TestingPrefStore(), 95 new TestingPrefStore(),
88 new DefaultPrefStore(), 96 new TestingPrefStore(),
89 new PrefNotifierImpl()) { 97 new PrefRegistrySimple(),
98 new PrefNotifierImpl()) {
90 } 99 }
91 100
92 TestingPrefServiceSyncable::~TestingPrefServiceSyncable() { 101 TestingPrefServiceSyncable::~TestingPrefServiceSyncable() {
93 } 102 }
94 103
95 ScopedTestingLocalState::ScopedTestingLocalState( 104 ScopedTestingLocalState::ScopedTestingLocalState(
96 TestingBrowserProcess* browser_process) 105 TestingBrowserProcess* browser_process)
97 : browser_process_(browser_process) { 106 : browser_process_(browser_process) {
98 chrome::RegisterLocalState(&local_state_); 107 chrome::RegisterLocalState(static_cast<PrefRegistrySimple*>(
108 local_state_.DeprecatedGetPrefRegistry()), &local_state_);
99 EXPECT_FALSE(browser_process->local_state()); 109 EXPECT_FALSE(browser_process->local_state());
100 browser_process->SetLocalState(&local_state_); 110 browser_process->SetLocalState(&local_state_);
101 } 111 }
102 112
103 ScopedTestingLocalState::~ScopedTestingLocalState() { 113 ScopedTestingLocalState::~ScopedTestingLocalState() {
104 EXPECT_EQ(&local_state_, browser_process_->local_state()); 114 EXPECT_EQ(&local_state_, browser_process_->local_state());
105 browser_process_->SetLocalState(NULL); 115 browser_process_->SetLocalState(NULL);
106 } 116 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_pref_service.h ('k') | chrome/test/reliability/page_load_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698