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

Unified Diff: chrome/browser/sync/engine/syncapi.cc

Issue 553015: Support for multiple sync ModelSafeWorkers.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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
« no previous file with comments | « chrome/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/engine/syncer_thread_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/syncapi.cc
===================================================================
--- chrome/browser/sync/engine/syncapi.cc (revision 36603)
+++ chrome/browser/sync/engine/syncapi.cc (working copy)
@@ -61,6 +61,8 @@
using browser_sync::AllStatusEvent;
using browser_sync::AuthWatcher;
using browser_sync::AuthWatcherEvent;
+using browser_sync::ModelSafeWorker;
+using browser_sync::ModelSafeWorkerRegistrar;
using browser_sync::Syncer;
using browser_sync::SyncerEvent;
using browser_sync::SyncerThread;
@@ -185,7 +187,6 @@
};
namespace sync_api {
-class ModelSafeWorkerBridge;
static const FilePath::CharType kBookmarkSyncUserSettingsDatabase[] =
FILE_PATH_LITERAL("BookmarkSyncSettings.sqlite3");
@@ -600,57 +601,6 @@
return transaction_;
}
-// An implementation of Visitor that we use to "visit" the
-// ModelSafeWorkerInterface provided by a client of this API. The object we
-// visit is responsible for calling DoWork, which will invoke Run() on it's
-// cached work closure.
-class ModelSafeWorkerVisitor : public ModelSafeWorkerInterface::Visitor {
- public:
- explicit ModelSafeWorkerVisitor(Closure* work) : work_(work) { }
- virtual ~ModelSafeWorkerVisitor() { }
-
- // ModelSafeWorkerInterface::Visitor implementation.
- virtual void DoWork() {
- work_->Run();
- }
-
- private:
- // The work to be done. We run this on DoWork and it cleans itself up
- // after it is run.
- Closure* work_;
-
- DISALLOW_COPY_AND_ASSIGN(ModelSafeWorkerVisitor);
-};
-
-// This class is declared in the cc file to allow inheritance from sync types.
-// The ModelSafeWorkerBridge is a liason between a syncapi-client defined
-// ModelSafeWorkerInterface and the actual ModelSafeWorker used by the Syncer
-// for the current SyncManager.
-class ModelSafeWorkerBridge : public browser_sync::ModelSafeWorker {
- public:
- // Takes ownership of |worker|.
- explicit ModelSafeWorkerBridge(ModelSafeWorkerInterface* worker)
- : worker_(worker) {
- }
- virtual ~ModelSafeWorkerBridge() { }
-
- // Overriding ModelSafeWorker.
- virtual void DoWorkAndWaitUntilDone(Closure* work) {
- // When the syncer has work to be done, we forward it to our worker who
- // will invoke DoWork on |visitor| when appropriate (from model safe
- // thread).
- ModelSafeWorkerVisitor visitor(work);
- worker_->CallDoWorkFromModelSafeThreadAndWait(&visitor);
- }
-
- private:
- // The worker that we can forward work requests to, to ensure the work
- // is performed on an appropriate model safe thread.
- scoped_ptr<ModelSafeWorkerInterface> worker_;
-
- DISALLOW_COPY_AND_ASSIGN(ModelSafeWorkerBridge);
-};
-
// A GaiaAuthenticator that uses HttpPostProviders instead of CURL.
class BridgedGaiaAuthenticator : public browser_sync::GaiaAuthenticator {
public:
@@ -717,7 +667,7 @@
bool use_ssl,
HttpPostProviderFactory* post_factory,
HttpPostProviderFactory* auth_post_factory,
- ModelSafeWorkerInterface* model_safe_worker,
+ ModelSafeWorkerRegistrar* model_safe_worker_registrar,
bool attempt_last_user_authentication,
const char* user_agent,
const std::string& lsid);
@@ -947,7 +897,7 @@
bool use_ssl,
HttpPostProviderFactory* post_factory,
HttpPostProviderFactory* auth_post_factory,
- ModelSafeWorkerInterface* model_safe_worker,
+ ModelSafeWorkerRegistrar* registrar,
bool attempt_last_user_authentication,
const char* user_agent,
const char* lsid) {
@@ -962,7 +912,7 @@
use_ssl,
post_factory,
auth_post_factory,
- model_safe_worker,
+ registrar,
attempt_last_user_authentication,
user_agent,
lsid);
@@ -987,7 +937,7 @@
const char* gaia_source,
bool use_ssl, HttpPostProviderFactory* post_factory,
HttpPostProviderFactory* auth_post_factory,
- ModelSafeWorkerInterface* model_safe_worker,
+ ModelSafeWorkerRegistrar* model_safe_worker_registrar,
bool attempt_last_user_authentication,
const char* user_agent,
const std::string& lsid) {
@@ -1059,11 +1009,8 @@
this, &SyncInternal::HandleAuthWatcherEvent));
// Build a SyncSessionContext and store the worker in it.
- // We set up both sides of the "bridge" here, with the ModelSafeWorkerBridge
- // on the Syncer side, and |model_safe_worker| on the API client side.
- ModelSafeWorkerBridge* worker = new ModelSafeWorkerBridge(model_safe_worker);
SyncSessionContext* context = new SyncSessionContext(
- connection_manager_.get(), dir_manager(), worker);
+ connection_manager_.get(), dir_manager(), model_safe_worker_registrar);
// The SyncerThread takes ownership of |context|.
syncer_thread_ = new SyncerThread(context, &allstatus_);
« no previous file with comments | « chrome/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/engine/syncer_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698