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

Side by Side Diff: chrome/browser/extensions/api/storage/settings_sync_unittest.cc

Issue 1165913002: [Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 6 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/memory/linked_ptr.h" 9 #include "base/memory/linked_ptr.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 private: 189 private:
190 // SettingsStorageFactory is refcounted. 190 // SettingsStorageFactory is refcounted.
191 ~TestingValueStoreFactory() override {} 191 ~TestingValueStoreFactory() override {}
192 192
193 // None of these storage areas are owned by this factory, so care must be 193 // None of these storage areas are owned by this factory, so care must be
194 // taken when calling GetExisting. 194 // taken when calling GetExisting.
195 std::map<std::string, TestingValueStore*> created_; 195 std::map<std::string, TestingValueStore*> created_;
196 }; 196 };
197 197
198 KeyedService* MockExtensionSystemFactoryFunction( 198 scoped_ptr<KeyedService> MockExtensionSystemFactoryFunction(
199 content::BrowserContext* context) { 199 content::BrowserContext* context) {
200 return new MockExtensionSystem(context); 200 return make_scoped_ptr(new MockExtensionSystem(context));
201 } 201 }
202 202
203 KeyedService* BuildEventRouter(content::BrowserContext* profile) { 203 scoped_ptr<KeyedService> BuildEventRouter(content::BrowserContext* profile) {
204 return new extensions::EventRouter(profile, nullptr); 204 return make_scoped_ptr(new extensions::EventRouter(profile, nullptr));
205 } 205 }
206 206
207 } // namespace 207 } // namespace
208 208
209 class ExtensionSettingsSyncTest : public testing::Test { 209 class ExtensionSettingsSyncTest : public testing::Test {
210 public: 210 public:
211 ExtensionSettingsSyncTest() 211 ExtensionSettingsSyncTest()
212 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), 212 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()),
213 file_thread_(BrowserThread::FILE, base::MessageLoop::current()), 213 file_thread_(BrowserThread::FILE, base::MessageLoop::current()),
214 storage_factory_(new util::ScopedSettingsStorageFactory()), 214 storage_factory_(new util::ScopedSettingsStorageFactory()),
215 sync_processor_(new MockSyncChangeProcessor), 215 sync_processor_(new MockSyncChangeProcessor),
216 sync_processor_wrapper_(new syncer::SyncChangeProcessorWrapperForTest( 216 sync_processor_wrapper_(new syncer::SyncChangeProcessorWrapperForTest(
217 sync_processor_.get())) {} 217 sync_processor_.get())) {}
218 218
219 void SetUp() override { 219 void SetUp() override {
220 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 220 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
221 profile_.reset(new TestingProfile(temp_dir_.path())); 221 profile_.reset(new TestingProfile(temp_dir_.path()));
222 storage_factory_->Reset(new LeveldbSettingsStorageFactory()); 222 storage_factory_->Reset(new LeveldbSettingsStorageFactory());
223 frontend_.reset( 223 frontend_ = StorageFrontend::CreateForTesting(storage_factory_,
224 StorageFrontend::CreateForTesting(storage_factory_, profile_.get())); 224 profile_.get()).Pass();
225 225
226 ExtensionsBrowserClient::Get() 226 ExtensionsBrowserClient::Get()
227 ->GetExtensionSystemFactory() 227 ->GetExtensionSystemFactory()
228 ->SetTestingFactoryAndUse(profile_.get(), 228 ->SetTestingFactoryAndUse(profile_.get(),
229 &MockExtensionSystemFactoryFunction); 229 &MockExtensionSystemFactoryFunction);
230 230
231 EventRouterFactory::GetInstance()->SetTestingFactory(profile_.get(), 231 EventRouterFactory::GetInstance()->SetTestingFactory(profile_.get(),
232 &BuildEventRouter); 232 &BuildEventRouter);
233 } 233 }
234 234
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 settings_namespace::SYNC, 1473 settings_namespace::SYNC,
1474 base::Bind(&UnlimitedSyncStorageTestCallback)); 1474 base::Bind(&UnlimitedSyncStorageTestCallback));
1475 frontend_->RunWithStorage(extension, 1475 frontend_->RunWithStorage(extension,
1476 settings_namespace::LOCAL, 1476 settings_namespace::LOCAL,
1477 base::Bind(&UnlimitedLocalStorageTestCallback)); 1477 base::Bind(&UnlimitedLocalStorageTestCallback));
1478 1478
1479 base::MessageLoop::current()->RunUntilIdle(); 1479 base::MessageLoop::current()->RunUntilIdle();
1480 } 1480 }
1481 1481
1482 } // namespace extensions 1482 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698