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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/public/test/fake_sync_service_factory.cc
diff --git a/ios/public/test/fake_sync_service_factory.cc b/ios/public/test/fake_sync_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1f85f8e18c3dd193efd0182d242bf2330cf82a53
--- /dev/null
+++ b/ios/public/test/fake_sync_service_factory.cc
@@ -0,0 +1,61 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/public/test/fake_sync_service_factory.h"
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "components/keyed_service/ios/browser_state_dependency_manager.h"
+#include "components/sync_driver/fake_sync_service.h"
+
+namespace {
+
+class KeyedFakeSyncService : public KeyedService {
+ public:
+ KeyedFakeSyncService(sync_driver::FakeSyncService* service)
+ : fake_sync_service_(service) {
+ DCHECK(fake_sync_service_);
+ }
+
+ sync_driver::FakeSyncService* fake_sync_service() {
+ return fake_sync_service_.get();
+ }
+
+ private:
+ scoped_ptr<sync_driver::FakeSyncService> fake_sync_service_;
+};
+
+} // namespace
+
+namespace ios {
+
+// static
+FakeSyncServiceFactory* FakeSyncServiceFactory::GetInstance() {
+ return Singleton<FakeSyncServiceFactory>::get();
+}
+
+// static
+sync_driver::FakeSyncService* FakeSyncServiceFactory::GetForBrowserState(
+ web::BrowserState* browser_state) {
+ return static_cast<KeyedFakeSyncService*>(
+ FakeSyncServiceFactory::GetInstance()->GetServiceForBrowserState(
+ browser_state, true))->fake_sync_service();
+}
+
+KeyedService* FakeSyncServiceFactory::BuildServiceInstanceFor(
+ web::BrowserState* context) const {
+ return new KeyedFakeSyncService(new sync_driver::FakeSyncService);
+}
+
+FakeSyncServiceFactory::FakeSyncServiceFactory()
+ : BrowserStateKeyedServiceFactory(
+ "FakeSyncService",
+ BrowserStateDependencyManager::GetInstance()) {
+}
+
+FakeSyncServiceFactory::~FakeSyncServiceFactory() {
+}
+
+} // namespace ios
« 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