diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-22 02:15:42 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-22 02:15:42 +0000 |
commit | d636be3840b26f0b886d2313c810c1f9057bbfdd (patch) | |
tree | 1ee1843858f305638fd3ae3cc8f24701db62dffe /chrome/browser/sync/sessions | |
parent | e41dd82ca759c41fe121da6200278e9d174a1461 (diff) | |
download | chromium_src-d636be3840b26f0b886d2313c810c1f9057bbfdd.zip chromium_src-d636be3840b26f0b886d2313c810c1f9057bbfdd.tar.gz chromium_src-d636be3840b26f0b886d2313c810c1f9057bbfdd.tar.bz2 |
Support for multiple sync ModelSafeWorkers.
- Introduce an equivalence class enum to group sync model types that live on the same
chrome native model together.
- Remove ModelSafeWorkerBridge as it is no longer needed.
- Rename BookmarkModelWorker -> UIModelWorker, and make it use the new stuff.
- Allow syncable entries belonging to an "unsynced" model type to be just
processed "passively" from
the SyncerThread (rather than dispatching), and allow this to change as a result
of enable/disabling.
- Experimenting with a way to complete issue 31909 (the CLASS_UNASSOCIATED
stuff).
BUG=31925,31911,31909
Review URL: http://codereview.chromium.org/553015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36835 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/sessions')
-rw-r--r-- | chrome/browser/sync/sessions/sync_session.cc | 17 | ||||
-rw-r--r-- | chrome/browser/sync/sessions/sync_session.h | 34 | ||||
-rw-r--r-- | chrome/browser/sync/sessions/sync_session_context.h | 15 | ||||
-rw-r--r-- | chrome/browser/sync/sessions/sync_session_unittest.cc | 11 |
4 files changed, 67 insertions, 10 deletions
diff --git a/chrome/browser/sync/sessions/sync_session.cc b/chrome/browser/sync/sessions/sync_session.cc index 296c532..5a0a3e8 100644 --- a/chrome/browser/sync/sessions/sync_session.cc +++ b/chrome/browser/sync/sessions/sync_session.cc @@ -14,6 +14,23 @@ SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate) write_transaction_(NULL), delegate_(delegate), auth_failure_occurred_(false) { + + std::vector<ModelSafeWorker*>* s = + const_cast<std::vector<ModelSafeWorker*>* >(&workers_); + context_->registrar()->GetWorkers(s); + + // TODO(tim): Use ModelSafeRoutingInfo to silo parts of the session status by + // ModelSafeGroup; + // e.g. have a map<class, commit_ids>, map<class, ConflictProgress> etc. + // The routing will be used to map multiple model types into the right silo. + // The routing info can't change throughout a session, so we're assured that + // (for example) commit_ids for syncable::AUTOFILL items that were being + // processed as part of the GROUP_PASSIVE run (because they weren't being + // synced) *continue* to be for this whole session, even though the + // ModelSafeWorkerRegistrar may be configured to route syncable::AUTOFILL to + // GROUP_DB now. + group_restriction_in_effect_ = false; + group_restriction_ = GROUP_PASSIVE; } SyncSessionSnapshot SyncSession::TakeSnapshot() const { diff --git a/chrome/browser/sync/sessions/sync_session.h b/chrome/browser/sync/sessions/sync_session.h index 4f44596..3d990a7 100644 --- a/chrome/browser/sync/sessions/sync_session.h +++ b/chrome/browser/sync/sessions/sync_session.h @@ -15,6 +15,7 @@ #define CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_H_ #include <string> +#include <vector> #include "base/basictypes.h" #include "base/scoped_ptr.h" @@ -29,6 +30,8 @@ class WriteTransaction; } namespace browser_sync { +class ModelSafeWorker; + namespace sessions { class SyncSession { @@ -99,11 +102,14 @@ class SyncSession { source_ = source; } + const std::vector<ModelSafeWorker*>& workers() const { return workers_; } + private: // Extend the encapsulation boundary to utilities for internal member // assignments. This way, the scope of these actions is explicit, they can't // be overridden, and assigning is always accompanied by unassigning. friend class ScopedSetSessionWriteTransaction; + friend class ScopedModelSafeGroupRestriction; // The context for this session, guaranteed to outlive |this|. SyncSessionContext* const context_; @@ -126,6 +132,14 @@ class SyncSession { // Used to determine if an auth error notification should be sent out. bool auth_failure_occurred_; + // The set of active ModelSafeWorkers for the duration of this session. + const std::vector<ModelSafeWorker*> workers_; + + // Used to fail read/write operations on this SyncSession that don't obey the + // currently active ModelSafeWorker contract. + bool group_restriction_in_effect_; + ModelSafeGroup group_restriction_; + DISALLOW_COPY_AND_ASSIGN(SyncSession); }; @@ -147,6 +161,26 @@ class ScopedSetSessionWriteTransaction { DISALLOW_COPY_AND_ASSIGN(ScopedSetSessionWriteTransaction); }; +// A utility to restrict access to only those parts of the given SyncSession +// that pertain to the specified ModelSafeGroup. See +// SyncSession::ModelSafetyRestriction. +class ScopedModelSafeGroupRestriction { + public: + ScopedModelSafeGroupRestriction(SyncSession* to_restrict, + ModelSafeGroup restriction) + : session_(to_restrict) { + DCHECK(!session_->group_restriction_in_effect_); + session_->group_restriction_in_effect_ = true; + session_->group_restriction_ = restriction; + } + ~ScopedModelSafeGroupRestriction() { + session_->group_restriction_in_effect_ = true; + } + private: + SyncSession* session_; + DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction); +}; + } // namespace sessions } // namespace browser_sync diff --git a/chrome/browser/sync/sessions/sync_session_context.h b/chrome/browser/sync/sessions/sync_session_context.h index 40deab1..3565ec6 100644 --- a/chrome/browser/sync/sessions/sync_session_context.h +++ b/chrome/browser/sync/sessions/sync_session_context.h @@ -31,6 +31,7 @@ class DirectoryManager; namespace browser_sync { class ConflictResolver; +class ModelSafeWorkerRegistrar; class ServerConnectionManager; namespace sessions { @@ -41,12 +42,12 @@ class SyncSessionContext { public: SyncSessionContext(ServerConnectionManager* connection_manager, syncable::DirectoryManager* directory_manager, - ModelSafeWorker* model_safe_worker) + ModelSafeWorkerRegistrar* model_safe_worker_registrar) : resolver_(NULL), syncer_event_channel_(NULL), connection_manager_(connection_manager), directory_manager_(directory_manager), - model_safe_worker_(model_safe_worker), + registrar_(model_safe_worker_registrar), extensions_activity_monitor_(new ExtensionsActivityMonitor()), notifications_enabled_(false) { } @@ -69,8 +70,8 @@ class SyncSessionContext { SyncerEventChannel* syncer_event_channel() { return syncer_event_channel_; } - ModelSafeWorker* model_safe_worker() { - return model_safe_worker_.get(); + ModelSafeWorkerRegistrar* registrar() { + return registrar_; } ExtensionsActivityMonitor* extensions_monitor() { return extensions_activity_monitor_; @@ -103,9 +104,9 @@ class SyncSessionContext { ServerConnectionManager* const connection_manager_; syncable::DirectoryManager* const directory_manager_; - // A worker capable of processing work closures on a thread that is - // guaranteed to be safe for model modifications. - scoped_ptr<ModelSafeWorker> model_safe_worker_; + // A registrar of workers capable of processing work closures on a thread + // that is guaranteed to be safe for model modifications. + ModelSafeWorkerRegistrar* registrar_; // We use this to stuff extensions activity into CommitMessages so the server // can correlate commit traffic with extension-related bookmark mutations. diff --git a/chrome/browser/sync/sessions/sync_session_unittest.cc b/chrome/browser/sync/sessions/sync_session_unittest.cc index e2a3c12..5ac602d 100644 --- a/chrome/browser/sync/sessions/sync_session_unittest.cc +++ b/chrome/browser/sync/sessions/sync_session_unittest.cc @@ -19,11 +19,12 @@ namespace sessions { namespace { class SyncSessionTest : public testing::Test, - public SyncSession::Delegate { + public SyncSession::Delegate, + public ModelSafeWorkerRegistrar { public: SyncSessionTest() : controller_invocations_allowed_(false) {} virtual void SetUp() { - context_.reset(new SyncSessionContext(NULL, NULL, NULL)); + context_.reset(new SyncSessionContext(NULL, NULL, this)); session_.reset(new SyncSession(context_.get(), this)); } virtual void TearDown() { @@ -47,6 +48,10 @@ class SyncSessionTest : public testing::Test, FailControllerInvocationIfDisabled("OnReceivedShortPollIntervalUpdate"); } + // ModelSafeWorkerRegistrar implementation. + virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) {} + virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {} + StatusController* status() { return session_->status_controller(); } protected: void FailControllerInvocationIfDisabled(const std::string& msg) { @@ -78,7 +83,7 @@ TEST_F(SyncSessionTest, SetWriteTransaction) { TestDirectorySetterUpper db; db.SetUp(); session_.reset(NULL); - context_.reset(new SyncSessionContext(NULL, db.manager(), NULL)); + context_.reset(new SyncSessionContext(NULL, db.manager(), this)); session_.reset(new SyncSession(context_.get(), this)); context_->set_account_name(db.name()); syncable::ScopedDirLookup dir(context_->directory_manager(), |