diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-01 22:22:32 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-01 22:22:32 +0000 |
commit | 179361d28afb77b096e7bfd43a4a26d11bb11969 (patch) | |
tree | 53f38410181812f5d23f2e4c2e8d719e3e5270df /chrome/browser/sync | |
parent | cf5912b5bacc1f615416be25b61c7126f06ee403 (diff) | |
download | chromium_src-179361d28afb77b096e7bfd43a4a26d11bb11969.zip chromium_src-179361d28afb77b096e7bfd43a4a26d11bb11969.tar.gz chromium_src-179361d28afb77b096e7bfd43a4a26d11bb11969.tar.bz2 |
sync: tiny cleanup in syncer.h/cc
Moves last bit of state from syncer to the sync session context, which is where we store state we want to carry over between sessions.
BUG=none
TEST=syncer_unittest
Review URL: http://codereview.chromium.org/6349030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73355 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r-- | chrome/browser/sync/engine/syncer.cc | 10 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncer.h | 9 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncer_unittest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/sync/sessions/sync_session_context.cc | 3 | ||||
-rw-r--r-- | chrome/browser/sync/sessions/sync_session_context.h | 11 |
5 files changed, 22 insertions, 16 deletions
diff --git a/chrome/browser/sync/engine/syncer.cc b/chrome/browser/sync/engine/syncer.cc index cbd7eef..b436c66 100644 --- a/chrome/browser/sync/engine/syncer.cc +++ b/chrome/browser/sync/engine/syncer.cc @@ -55,7 +55,6 @@ using sessions::ConflictProgress; Syncer::Syncer() : early_exit_requested_(false), - max_commit_batch_size_(kDefaultMaxCommitBatchSize), pre_conflict_resolution_closure_(NULL) { } @@ -183,7 +182,8 @@ void Syncer::SyncShare(sessions::SyncSession* session, sessions::ScopedSetSessionWriteTransaction set_trans(session, &trans); VLOG(1) << "Getting the Commit IDs"; - GetCommitIdsCommand get_commit_ids_command(max_commit_batch_size_); + GetCommitIdsCommand get_commit_ids_command( + session->context()->max_commit_batch_size()); get_commit_ids_command.Execute(session); if (!session->status_controller()->commit_ids().empty()) { @@ -289,8 +289,10 @@ void Syncer::ProcessClientCommand(sessions::SyncSession* session) { const ClientCommand& command = response.client_command(); // The server limits the number of items a client can commit in one batch. - if (command.has_max_commit_batch_size()) - max_commit_batch_size_ = command.max_commit_batch_size(); + if (command.has_max_commit_batch_size()) { + session->context()->set_max_commit_batch_size( + command.max_commit_batch_size()); + } if (command.has_set_sync_long_poll_interval()) { session->delegate()->OnReceivedLongPollIntervalUpdate( TimeDelta::FromSeconds(command.set_sync_long_poll_interval())); diff --git a/chrome/browser/sync/engine/syncer.h b/chrome/browser/sync/engine/syncer.h index f1a63be..bbcbb3b 100644 --- a/chrome/browser/sync/engine/syncer.h +++ b/chrome/browser/sync/engine/syncer.h @@ -41,8 +41,6 @@ class SyncProcessState; class URLFactory; struct HttpResponse; -static const int kDefaultMaxCommitBatchSize = 25; - enum SyncerStep { SYNCER_BEGIN, CLEANUP_DISABLED_TYPES, @@ -91,12 +89,7 @@ class Syncer { // operation and honor server mandated throttles. virtual void SyncShare(sessions::SyncSession* session); - // Limit the batch size of commit operations to a specified number of items. - void set_max_commit_batch_size(int x) { max_commit_batch_size_ = x; } - private: - void RequestNudge(int milliseconds); - // Implements the PROCESS_CLIENT_COMMAND syncer step. void ProcessClientCommand(sessions::SyncSession *session); @@ -111,8 +104,6 @@ class Syncer { bool early_exit_requested_; base::Lock early_exit_requested_lock_; - int32 max_commit_batch_size_; - ConflictResolver resolver_; // A callback hook used in unittests to simulate changes between conflict set diff --git a/chrome/browser/sync/engine/syncer_unittest.cc b/chrome/browser/sync/engine/syncer_unittest.cc index 9af46c6..57f8eda 100644 --- a/chrome/browser/sync/engine/syncer_unittest.cc +++ b/chrome/browser/sync/engine/syncer_unittest.cc @@ -26,6 +26,7 @@ #include "chrome/browser/sync/engine/syncer_util.h" #include "chrome/browser/sync/engine/syncproto.h" #include "chrome/browser/sync/protocol/sync.pb.h" +#include "chrome/browser/sync/sessions/sync_session_context.h" #include "chrome/browser/sync/syncable/directory_manager.h" #include "chrome/browser/sync/syncable/model_type.h" #include "chrome/browser/sync/syncable/syncable.h" @@ -718,7 +719,7 @@ TEST_F(SyncerTest, TestCommitListOrderingThreeItemsTall) { } TEST_F(SyncerTest, TestCommitListOrderingThreeItemsTallLimitedSize) { - syncer_->set_max_commit_batch_size(2); + context_->set_max_commit_batch_size(2); CommitOrderingTest items[] = { {1, ids_.FromNumber(-2001), ids_.FromNumber(-2000)}, {0, ids_.FromNumber(-2000), ids_.FromNumber(0)}, @@ -771,7 +772,7 @@ TEST_F(SyncerTest, TestCommitListOrderingTwoLongDeletedItemWithUnroll) { } TEST_F(SyncerTest, TestCommitListOrdering3LongDeletedItemsWithSizeLimit) { - syncer_->set_max_commit_batch_size(2); + context_->set_max_commit_batch_size(2); CommitOrderingTest items[] = { {0, ids_.FromNumber(1000), ids_.FromNumber(0), {DELETED, OLD_MTIME}}, {1, ids_.FromNumber(1001), ids_.FromNumber(0), {DELETED, OLD_MTIME}}, diff --git a/chrome/browser/sync/sessions/sync_session_context.cc b/chrome/browser/sync/sessions/sync_session_context.cc index dbb4da6..6b0e91e 100644 --- a/chrome/browser/sync/sessions/sync_session_context.cc +++ b/chrome/browser/sync/sessions/sync_session_context.cc @@ -21,7 +21,8 @@ SyncSessionContext::SyncSessionContext( directory_manager_(directory_manager), registrar_(model_safe_worker_registrar), extensions_activity_monitor_(new ExtensionsActivityMonitor()), - notifications_enabled_(false) { + notifications_enabled_(false), + max_commit_batch_size_(kDefaultMaxCommitBatchSize) { std::vector<SyncEngineEventListener*>::const_iterator it; for (it = listeners.begin(); it != listeners.end(); ++it) listeners_.AddObserver(*it); diff --git a/chrome/browser/sync/sessions/sync_session_context.h b/chrome/browser/sync/sessions/sync_session_context.h index 2fe8832..3f402ae 100644 --- a/chrome/browser/sync/sessions/sync_session_context.h +++ b/chrome/browser/sync/sessions/sync_session_context.h @@ -36,6 +36,9 @@ class ExtensionsActivityMonitor; class ModelSafeWorkerRegistrar; class ServerConnectionManager; +// Default number of items a client can commit in a single message. +static const int kDefaultMaxCommitBatchSize = 25; + namespace sessions { class ScopedSessionContextConflictResolver; struct SyncSessionSnapshot; @@ -76,6 +79,11 @@ class SyncSessionContext { } const std::string& account_name() { return account_name_; } + void set_max_commit_batch_size(int batch_size) { + max_commit_batch_size_ = batch_size; + } + int32 max_commit_batch_size() const { return max_commit_batch_size_; } + const ModelSafeRoutingInfo& previous_session_routing_info() const { return previous_session_routing_info_; } @@ -126,6 +134,9 @@ class SyncSessionContext { // The name of the account being synced. std::string account_name_; + // The server limits the number of items a client can commit in one batch. + int max_commit_batch_size_; + // Some routing info history to help us clean up types that get disabled // by the user. ModelSafeRoutingInfo previous_session_routing_info_; |