| 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..e3fd31fc80debb5aa82a046153a21f29c3f7598a
|
| --- /dev/null
|
| +++ b/chrome/browser/sync/glue/sync_start_util.cc
|
| @@ -0,0 +1,51 @@
|
| +// 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 "base/files/file_path.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 {
|
| +
|
| +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));
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +namespace sync_start_util {
|
| +
|
| +syncer::SyncableService::StartSyncFlare GetFlareForSyncableService(
|
| + const base::FilePath& profile_path) {
|
| + return base::Bind(&StartSyncProxy, profile_path);
|
| +}
|
| +
|
| +} // namespace sync_start_util
|
|
|