summaryrefslogtreecommitdiffstats
path: root/sync/sessions
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-30 18:21:17 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-30 18:21:17 +0000
commite05b9d1361a9b8e1666cf569f3d0bb72a56828e0 (patch)
treee7c882fefc4aee9105ca418596c95250fb57e84c /sync/sessions
parente7b852280537f8a6eebe82b4cbec8ed9267d1092 (diff)
downloadchromium_src-e05b9d1361a9b8e1666cf569f3d0bb72a56828e0.zip
chromium_src-e05b9d1361a9b8e1666cf569f3d0bb72a56828e0.tar.gz
chromium_src-e05b9d1361a9b8e1666cf569f3d0bb72a56828e0.tar.bz2
sync: Implement per-type update processing
Introduces a new class that represents a syncable::Directory's udpate requesting and processing capabilities. The intention is that this will eventually be expanded to cover commits as well. Eventually, this will be used as the basis for an interface between sync and Some update logic has been moved into this SyncDirectoryUpdateHandler class or download.cc. The rest of it can be found in process_update_util.cc, the successor to the old ProcessUpdatesCommand. The StoreTimestampsCommand has been entirely removed. The unit tests associated with these SyncerCommands have been ported to sync_directory_update_handler_unittest.cc. Except for a few error scenarios that are now handled differently, the observable behavior of the client should not be changed by this CL. BUG=278484 Review URL: https://codereview.chromium.org/38803003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/sessions')
-rw-r--r--sync/sessions/sync_session_context.cc13
-rw-r--r--sync/sessions/sync_session_context.h13
2 files changed, 24 insertions, 2 deletions
diff --git a/sync/sessions/sync_session_context.cc b/sync/sessions/sync_session_context.cc
index 78b3442..d44591d 100644
--- a/sync/sessions/sync_session_context.cc
+++ b/sync/sessions/sync_session_context.cc
@@ -23,6 +23,7 @@ SyncSessionContext::SyncSessionContext(
const std::string& invalidator_client_id)
: connection_manager_(connection_manager),
directory_(directory),
+ update_handler_deleter_(&update_handler_map_),
commit_contributor_deleter_(&commit_contributor_map_),
extensions_activity_(extensions_activity),
notifications_enabled_(false),
@@ -50,14 +51,22 @@ void SyncSessionContext::set_routing_info(
routing_info_ = routing_info;
// TODO(rlarocque): This is not a good long-term solution. We must find a
- // better way to initialize the set of CommitContributors.
- STLDeleteValues<CommitContributorMap>(&commit_contributor_map_);
+ // better way to initialize the set of CommitContributors and UpdateHandlers.
ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info);
+
+ STLDeleteValues<CommitContributorMap>(&commit_contributor_map_);
for (ModelTypeSet::Iterator it = enabled_types.First(); it.Good(); it.Inc()) {
SyncDirectoryCommitContributor* contributor =
new SyncDirectoryCommitContributor(directory(), it.Get());
commit_contributor_map_.insert(std::make_pair(it.Get(), contributor));
}
+
+ STLDeleteValues<UpdateHandlerMap>(&update_handler_map_);
+ for (ModelTypeSet::Iterator it = enabled_types.First(); it.Good(); it.Inc()) {
+ SyncDirectoryUpdateHandler* handler =
+ new SyncDirectoryUpdateHandler(directory(), it.Get());
+ update_handler_map_.insert(std::make_pair(it.Get(), handler));
+ }
}
} // namespace sessions
diff --git a/sync/sessions/sync_session_context.h b/sync/sessions/sync_session_context.h
index 3133c32..d195943 100644
--- a/sync/sessions/sync_session_context.h
+++ b/sync/sessions/sync_session_context.h
@@ -25,6 +25,7 @@
#include "base/stl_util.h"
#include "sync/base/sync_export.h"
#include "sync/engine/sync_directory_commit_contributor.h"
+#include "sync/engine/sync_directory_update_handler.h"
#include "sync/engine/sync_engine_event.h"
#include "sync/engine/syncer_types.h"
#include "sync/engine/traffic_recorder.h"
@@ -75,6 +76,10 @@ class SYNC_EXPORT_PRIVATE SyncSessionContext {
void set_routing_info(const ModelSafeRoutingInfo& routing_info);
+ UpdateHandlerMap* update_handler_map() {
+ return &update_handler_map_;
+ }
+
CommitContributorMap* commit_contributor_map() {
return &commit_contributor_map_;
}
@@ -158,6 +163,14 @@ class SYNC_EXPORT_PRIVATE SyncSessionContext {
// Must be updated manually when SBR's state is modified.
ModelSafeRoutingInfo routing_info_;
+ // A map of 'update handlers', one for each enabled type.
+ // This must be kept in sync with the routing info. Our temporary solution to
+ // that problem is to initialize this map in set_routing_info().
+ UpdateHandlerMap update_handler_map_;
+
+ // Deleter for the |update_handler_map_|.
+ STLValueDeleter<UpdateHandlerMap> update_handler_deleter_;
+
// A map of 'commit contributors', one for each enabled type.
// This must be kept in sync with the routing info. Our temporary solution to
// that problem is to initialize this map in set_routing_info().