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

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

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add to PrefRegistrySyncable and PrefServiceSyncable to let sync know of pre-registered prefs. 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
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/compiler_specific.h"
9 #include "base/prefs/default_pref_store.h" 9 #include "base/prefs/default_pref_store.h"
10 #include "chrome/browser/prefs/browser_prefs.h" 10 #include "chrome/browser/prefs/browser_prefs.h"
11 #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" 12 #include "chrome/browser/prefs/pref_registry_simple.h"
13 #include "chrome/browser/prefs/pref_registry_syncable.h"
13 #include "chrome/browser/prefs/pref_value_store.h" 14 #include "chrome/browser/prefs/pref_value_store.h"
14 #include "chrome/test/base/testing_browser_process.h" 15 #include "chrome/test/base/testing_browser_process.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace { 18 namespace {
18 19
19 // Do-nothing implementation for TestingPrefService. 20 // Do-nothing implementation for TestingPrefService.
20 void HandleReadError(PersistentPrefStore::PrefReadError error) { 21 void HandleReadError(PersistentPrefStore::PrefReadError error) {
21 } 22 }
22 23
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 : PrefServiceSyncable(pref_notifier, 58 : PrefServiceSyncable(pref_notifier,
58 new PrefValueStore( 59 new PrefValueStore(
59 managed_prefs, 60 managed_prefs,
60 NULL, 61 NULL,
61 NULL, 62 NULL,
62 user_prefs, 63 user_prefs,
63 recommended_prefs, 64 recommended_prefs,
64 pref_registry->defaults(), 65 pref_registry->defaults(),
65 pref_notifier), 66 pref_notifier),
66 user_prefs, 67 user_prefs,
67 pref_registry, 68 static_cast<PrefRegistrySyncable*>(pref_registry),
68 base::Bind(&HandleReadError), 69 base::Bind(&HandleReadError),
69 false), 70 false),
70 managed_prefs_(managed_prefs), 71 managed_prefs_(managed_prefs),
71 user_prefs_(user_prefs), 72 user_prefs_(user_prefs),
72 recommended_prefs_(recommended_prefs) { 73 recommended_prefs_(recommended_prefs) {
73 } 74 }
74 75
75 TestingPrefServiceSimple::TestingPrefServiceSimple() 76 TestingPrefServiceSimple::TestingPrefServiceSimple()
76 : TestingPrefServiceBase<PrefService>( 77 : TestingPrefServiceBase<PrefService>(
77 new TestingPrefStore(), 78 new TestingPrefStore(),
78 new TestingPrefStore(), 79 new TestingPrefStore(),
79 new TestingPrefStore(), 80 new TestingPrefStore(),
80 new PrefRegistrySimple(), 81 new PrefRegistrySimple(),
81 new PrefNotifierImpl()) { 82 new PrefNotifierImpl()) {
82 } 83 }
83 84
84 TestingPrefServiceSimple::~TestingPrefServiceSimple() { 85 TestingPrefServiceSimple::~TestingPrefServiceSimple() {
85 } 86 }
86 87
87 PrefRegistrySimple* TestingPrefServiceSimple::registry() { 88 PrefRegistrySimple* TestingPrefServiceSimple::registry() {
88 return static_cast<PrefRegistrySimple*>(DeprecatedGetPrefRegistry()); 89 return static_cast<PrefRegistrySimple*>(DeprecatedGetPrefRegistry());
89 } 90 }
90 91
91 // TODO(joi): Switch to PrefRegistrySyncable once available.
92 TestingPrefServiceSyncable::TestingPrefServiceSyncable() 92 TestingPrefServiceSyncable::TestingPrefServiceSyncable()
93 : TestingPrefServiceBase<PrefServiceSyncable>( 93 : TestingPrefServiceBase<PrefServiceSyncable>(
94 new TestingPrefStore(), 94 new TestingPrefStore(),
95 new TestingPrefStore(), 95 new TestingPrefStore(),
96 new TestingPrefStore(), 96 new TestingPrefStore(),
97 new PrefRegistrySimple(), 97 new PrefRegistrySyncable(),
98 new PrefNotifierImpl()) { 98 new PrefNotifierImpl()) {
99 } 99 }
100 100
101 TestingPrefServiceSyncable::~TestingPrefServiceSyncable() { 101 TestingPrefServiceSyncable::~TestingPrefServiceSyncable() {
102 } 102 }
103 103
104 PrefRegistrySyncable* TestingPrefServiceSyncable::registry() {
105 return static_cast<PrefRegistrySyncable*>(DeprecatedGetPrefRegistry());
106 }
107
104 ScopedTestingLocalState::ScopedTestingLocalState( 108 ScopedTestingLocalState::ScopedTestingLocalState(
105 TestingBrowserProcess* browser_process) 109 TestingBrowserProcess* browser_process)
106 : browser_process_(browser_process) { 110 : browser_process_(browser_process) {
107 chrome::RegisterLocalState(static_cast<PrefRegistrySimple*>( 111 chrome::RegisterLocalState(&local_state_,
108 local_state_.DeprecatedGetPrefRegistry()), &local_state_); 112 static_cast<PrefRegistrySimple*>(
113 local_state_.DeprecatedGetPrefRegistry()));
Mattias Nissler (ping if slow) 2013/02/06 17:53:33 local_state_ is a TestingPrefServiceSimple - local
Jói 2013/02/07 14:52:32 Done.
109 EXPECT_FALSE(browser_process->local_state()); 114 EXPECT_FALSE(browser_process->local_state());
110 browser_process->SetLocalState(&local_state_); 115 browser_process->SetLocalState(&local_state_);
111 } 116 }
112 117
113 ScopedTestingLocalState::~ScopedTestingLocalState() { 118 ScopedTestingLocalState::~ScopedTestingLocalState() {
114 EXPECT_EQ(&local_state_, browser_process_->local_state()); 119 EXPECT_EQ(&local_state_, browser_process_->local_state());
115 browser_process_->SetLocalState(NULL); 120 browser_process_->SetLocalState(NULL);
116 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698