forked from sanyaade-mobiledev/chromium.src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync: SyncableService support for starting sync.
Still has no actual effect as operational bits are behind the --sync-enable-deferred-startup flag. If you pass that flag, autofill will now be permitted to kick off sync init (in fact, it will be the only thing that can kick off sync init, so you probably don't want to pass the flag yet!). Next I'll add a fallback timer and plumb the flare to more datatypes; non Sync API types will have to call ProfileSyncService directly. TBR=dhollowa@chromium.org ^ For web_data_service_factory as changes are just basic consequence of the parameter change to AutocompleteSyncableService already LGTM'd. BUG=80194 Review URL: https://chromiumcodereview.appspot.com/14018026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198309 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
tim@chromium.org
committed
May 4, 2013
1 parent
bc1d60e
commit 67c7e0a
Showing
9 changed files
with
187 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 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. | ||
// | ||
// Various utilities for kicking off sync initialization from data types or | ||
// other services. | ||
|
||
#ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_START_UTIL_H_ | ||
#define CHROME_BROWSER_SYNC_GLUE_SYNC_START_UTIL_H_ | ||
|
||
#include "sync/api/syncable_service.h" | ||
|
||
namespace base { | ||
class FilePath; | ||
} | ||
|
||
namespace sync_start_util { | ||
|
||
// Creates a StartSyncFlare that a SyncableService can use to tell | ||
// ProfileSyncService it needs sync to start ASAP. Typically this would be | ||
// given to the SyncableService on construction. | ||
// | ||
// The flare built by this function is designed to be Run()able from any thread | ||
// so that non-UI types don't have to deal with posting tasks. | ||
// | ||
// |profile_path| is used to get a hold of the actual Profile* once the | ||
// request to start sync is safely in UI Thread land. | ||
syncer::SyncableService::StartSyncFlare GetFlareForSyncableService( | ||
const base::FilePath& profile_path); | ||
|
||
} // namespace sync_start_util | ||
|
||
#endif // CHROME_BROWSER_SYNC_GLUE_SYNC_START_UTIL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters