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

Unified Diff: chrome/browser/sync/glue/sync_start_util.cc

Issue 14018026: sync: SyncableService support for starting sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
Index: chrome/browser/sync/glue/sync_start_util.cc
diff --git a/chrome/browser/sync/glue/sync_start_util.cc b/chrome/browser/sync/glue/sync_start_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9f6e4b6d9d6701f41779085d68f411c353e08675
--- /dev/null
+++ b/chrome/browser/sync/glue/sync_start_util.cc
@@ -0,0 +1,45 @@
+// Copyright 2013 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 "chrome/browser/sync/glue/sync_start_util.h"
+
+#include "base/bind.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace sync_start_util {
+void StartSyncOnUIThread(const base::FilePath& profile,
+ syncer::ModelType type) {
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ Profile* p = profile_manager->GetProfileByPath(profile);
+ if (!p) {
+ DVLOG(2) << "Profile not found, can't start sync.";
+ return;
+ }
+
+ ProfileSyncService* service = ProfileSyncServiceFactory::GetForProfile(p);
+ if (!service) {
+ DVLOG(2) << "No ProfileSyncService for profile, can't start sync.";
+ return;
+ }
+ service->OnDataTypeRequestsSyncStartup(type);
+}
+
+void StartSyncProxy(const base::FilePath& profile,
+ syncer::ModelType type) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&StartSyncOnUIThread, profile, type));
+}
+
+syncer::StartSyncFlare GetFlareForSyncableService(
+ const base::FilePath& profile_path) {
+ return base::Bind(&StartSyncProxy, profile_path);
+}
+
+} // namespace sync_start_util

Powered by Google App Engine
This is Rietveld 408576698