This source file includes following definitions.
- StartSyncOnUIThread
- StartSyncProxy
- GetFlareForSyncableService
#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();
if (!profile_manager) {
DVLOG(2) << "No ProfileManager, can't start sync.";
return;
}
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 sync_start_util {
syncer::SyncableService::StartSyncFlare GetFlareForSyncableService(
const base::FilePath& profile_path) {
return base::Bind(&StartSyncProxy, profile_path);
}
}