Chromium Code Reviews| 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, |
|
Nicolas Zea
2013/05/01 22:37:04
have these two methods be within an anon namespace
tim (not reviewing)
2013/05/03 00:20:51
Done.
|
| + 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 |