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

Side by Side Diff: chrome/browser/extensions/settings/settings_test_util.cc

Issue 8670012: Extension Settings API: move the API functions into an object SettingsNamepace, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug / sync Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/settings/settings_test_util.h" 5 #include "chrome/browser/extensions/settings/settings_test_util.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "chrome/common/extensions/extension.h" 8 #include "chrome/common/extensions/extension.h"
9 #include "chrome/browser/extensions/settings/settings_frontend.h" 9 #include "chrome/browser/extensions/settings/settings_frontend.h"
10 #include "chrome/browser/extensions/settings/settings_namespace.h"
10 11
11 namespace extensions { 12 namespace extensions {
12 13
13 namespace settings_test_util { 14 namespace settings_test_util {
14 15
15 // Intended as a StorageCallback from GetStorage. 16 // Intended as a StorageCallback from GetStorage.
16 static void AssignStorage(SettingsStorage** dst, SettingsStorage* src) { 17 static void AssignStorage(SettingsStorage** dst, SettingsStorage* src) {
17 *dst = src; 18 *dst = src;
18 } 19 }
19 20
20 SettingsStorage* GetStorage( 21 SettingsStorage* GetStorage(
21 const std::string& extension_id, SettingsFrontend* frontend) { 22 const std::string& extension_id, SettingsFrontend* frontend) {
22 SettingsStorage* storage = NULL; 23 SettingsStorage* storage = NULL;
23 frontend->RunWithStorage( 24 frontend->RunWithStorage(
24 extension_id, 25 extension_id,
26 settings_namespace::SYNC,
25 base::Bind(&AssignStorage, &storage)); 27 base::Bind(&AssignStorage, &storage));
26 MessageLoop::current()->RunAllPending(); 28 MessageLoop::current()->RunAllPending();
27 return storage; 29 return storage;
28 } 30 }
29 31
30 // MockExtensionService 32 // MockExtensionService
31 33
32 MockExtensionService::MockExtensionService() {} 34 MockExtensionService::MockExtensionService() {}
33 35
34 MockExtensionService::~MockExtensionService() {} 36 MockExtensionService::~MockExtensionService() {}
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 static_cast<ExtensionServiceInterface*>(&extension_service_); 95 static_cast<ExtensionServiceInterface*>(&extension_service_);
94 return static_cast<ExtensionService*>(as_interface); 96 return static_cast<ExtensionService*>(as_interface);
95 } 97 }
96 98
97 ExtensionEventRouter* MockProfile::GetExtensionEventRouter() { 99 ExtensionEventRouter* MockProfile::GetExtensionEventRouter() {
98 return event_router_.get(); 100 return event_router_.get();
99 } 101 }
100 102
101 // ScopedSettingsFactory 103 // ScopedSettingsFactory
102 104
105 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory() {}
106
103 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory( 107 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory(
104 SettingsStorageFactory* delegate) : delegate_(delegate) { 108 const scoped_refptr<SettingsStorageFactory>& delegate)
105 DCHECK(delegate); 109 : delegate_(delegate) {}
106 }
107 110
108 ScopedSettingsStorageFactory::~ScopedSettingsStorageFactory() {} 111 ScopedSettingsStorageFactory::~ScopedSettingsStorageFactory() {}
109 112
110 void ScopedSettingsStorageFactory::Reset(SettingsStorageFactory* delegate) { 113 void ScopedSettingsStorageFactory::Reset(
111 DCHECK(delegate); 114 const scoped_refptr<SettingsStorageFactory>& delegate) {
112 delegate_.reset(delegate); 115 delegate_ = delegate;
113 } 116 }
114 117
115 SettingsStorage* ScopedSettingsStorageFactory::Create( 118 SettingsStorage* ScopedSettingsStorageFactory::Create(
116 const FilePath& base_path, const std::string& extension_id) { 119 const FilePath& base_path, const std::string& extension_id) {
120 DCHECK(delegate_.get());
117 return delegate_->Create(base_path, extension_id); 121 return delegate_->Create(base_path, extension_id);
118 } 122 }
119 123
120 } // namespace settings_test_util 124 } // namespace settings_test_util
121 125
122 } // namespace extensions 126 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698