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

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

Issue 1663783002: Remove the //ios/public/test target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ios_tests
Patch Set: Add missing forwarding-header Created 4 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
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/singleton.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 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state. h"
13
14 namespace {
15
16 class KeyedFakeSyncService : public KeyedService {
17 public:
18 KeyedFakeSyncService() {}
19
20 sync_driver::FakeSyncService* fake_sync_service() {
21 return &fake_sync_service_;
22 }
23
24 private:
25 sync_driver::FakeSyncService fake_sync_service_;
26 };
27
28 } // namespace
29
30 namespace ios {
31
32 // static
33 FakeSyncServiceFactory* FakeSyncServiceFactory::GetInstance() {
34 return base::Singleton<FakeSyncServiceFactory>::get();
35 }
36
37 // static
38 sync_driver::FakeSyncService* FakeSyncServiceFactory::GetForBrowserState(
39 ios::ChromeBrowserState* browser_state) {
40 return static_cast<KeyedFakeSyncService*>(
41 FakeSyncServiceFactory::GetInstance()->GetServiceForBrowserState(
42 browser_state, true))->fake_sync_service();
43 }
44
45 // static
46 sync_driver::FakeSyncService*
47 FakeSyncServiceFactory::GetForBrowserStateIfExists(
48 ios::ChromeBrowserState* browser_state) {
49 return static_cast<KeyedFakeSyncService*>(
50 FakeSyncServiceFactory::GetInstance()->GetServiceForBrowserState(
51 browser_state, false))->fake_sync_service();
52 }
53
54 FakeSyncServiceFactory::FakeSyncServiceFactory()
55 : BrowserStateKeyedServiceFactory(
56 "FakeSyncService",
57 BrowserStateDependencyManager::GetInstance()) {
58 }
59
60 FakeSyncServiceFactory::~FakeSyncServiceFactory() {
61 }
62
63 scoped_ptr<KeyedService> FakeSyncServiceFactory::BuildServiceInstanceFor(
64 web::BrowserState* context) const {
65 return make_scoped_ptr(new KeyedFakeSyncService);
66 }
67
68 } // 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