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.
5 #include "ios/public/test/fake_sync_service_factory.h"
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"
16 class KeyedFakeSyncService
: public KeyedService
{
18 KeyedFakeSyncService() {}
20 sync_driver::FakeSyncService
* fake_sync_service() {
21 return &fake_sync_service_
;
25 sync_driver::FakeSyncService fake_sync_service_
;
33 FakeSyncServiceFactory
* FakeSyncServiceFactory::GetInstance() {
34 return Singleton
<FakeSyncServiceFactory
>::get();
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();
45 FakeSyncServiceFactory::FakeSyncServiceFactory()
46 : BrowserStateKeyedServiceFactory(
48 BrowserStateDependencyManager::GetInstance()) {
51 FakeSyncServiceFactory::~FakeSyncServiceFactory() {
54 scoped_ptr
<KeyedService
> FakeSyncServiceFactory::BuildServiceInstanceFor(
55 web::BrowserState
* context
) const {
56 return make_scoped_ptr(new KeyedFakeSyncService
);