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

Side by Side Diff: ios/public/test/fake_sync_service_factory.cc

Issue 1158223003: [iOS] Add FakeSyncService and factory for testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/public/test/fake_sync_service_factory.h"
6
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "components/keyed_service/core/keyed_service.h"
10 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
11 #include "components/sync_driver/fake_sync_service.h"
12
13 namespace {
14
15 class KeyedFakeSyncService : public KeyedService {
16 public:
17 KeyedFakeSyncService(sync_driver::FakeSyncService* service)
18 : fake_sync_service_(service) {
19 DCHECK(fake_sync_service_);
20 }
21
22 sync_driver::FakeSyncService* fake_sync_service() {
23 return fake_sync_service_.get();
24 }
25
26 private:
27 scoped_ptr<sync_driver::FakeSyncService> fake_sync_service_;
28 };
29
30 } // namespace
31
32 namespace ios {
33
34 // static
35 FakeSyncServiceFactory* FakeSyncServiceFactory::GetInstance() {
36 return Singleton<FakeSyncServiceFactory>::get();
37 }
38
39 // static
40 sync_driver::FakeSyncService* FakeSyncServiceFactory::GetForBrowserState(
41 web::BrowserState* browser_state) {
42 return static_cast<KeyedFakeSyncService*>(
43 FakeSyncServiceFactory::GetInstance()->GetServiceForBrowserState(
44 browser_state, true))->fake_sync_service();
45 }
46
47 KeyedService* FakeSyncServiceFactory::BuildServiceInstanceFor(
48 web::BrowserState* context) const {
49 return new KeyedFakeSyncService(new sync_driver::FakeSyncService);
50 }
51
52 FakeSyncServiceFactory::FakeSyncServiceFactory()
53 : BrowserStateKeyedServiceFactory(
54 "FakeSyncService",
55 BrowserStateDependencyManager::GetInstance()) {
56 }
57
58 FakeSyncServiceFactory::~FakeSyncServiceFactory() {
59 }
60
61 } // namespace ios
OLDNEW
« no previous file with comments | « ios/public/test/fake_sync_service_factory.h ('k') | ios/public/test/test_chrome_browser_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698