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

Side by Side Diff: sync/sessions/sync_session_context.cc

Issue 38803003: sync: Implement per-type update processing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/sessions/sync_session_context.h ('k') | sync/sync_core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/sessions/sync_session_context.h" 5 #include "sync/sessions/sync_session_context.h"
6 6
7 #include "sync/sessions/debug_info_getter.h" 7 #include "sync/sessions/debug_info_getter.h"
8 #include "sync/util/extensions_activity.h" 8 #include "sync/util/extensions_activity.h"
9 9
10 namespace syncer { 10 namespace syncer {
11 namespace sessions { 11 namespace sessions {
12 12
13 SyncSessionContext::SyncSessionContext( 13 SyncSessionContext::SyncSessionContext(
14 ServerConnectionManager* connection_manager, 14 ServerConnectionManager* connection_manager,
15 syncable::Directory* directory, 15 syncable::Directory* directory,
16 const std::vector<ModelSafeWorker*>& workers, 16 const std::vector<ModelSafeWorker*>& workers,
17 ExtensionsActivity* extensions_activity, 17 ExtensionsActivity* extensions_activity,
18 const std::vector<SyncEngineEventListener*>& listeners, 18 const std::vector<SyncEngineEventListener*>& listeners,
19 DebugInfoGetter* debug_info_getter, 19 DebugInfoGetter* debug_info_getter,
20 TrafficRecorder* traffic_recorder, 20 TrafficRecorder* traffic_recorder,
21 bool keystore_encryption_enabled, 21 bool keystore_encryption_enabled,
22 bool client_enabled_pre_commit_update_avoidance, 22 bool client_enabled_pre_commit_update_avoidance,
23 const std::string& invalidator_client_id) 23 const std::string& invalidator_client_id)
24 : connection_manager_(connection_manager), 24 : connection_manager_(connection_manager),
25 directory_(directory), 25 directory_(directory),
26 update_handler_deleter_(&update_handler_map_),
26 commit_contributor_deleter_(&commit_contributor_map_), 27 commit_contributor_deleter_(&commit_contributor_map_),
27 extensions_activity_(extensions_activity), 28 extensions_activity_(extensions_activity),
28 notifications_enabled_(false), 29 notifications_enabled_(false),
29 max_commit_batch_size_(kDefaultMaxCommitBatchSize), 30 max_commit_batch_size_(kDefaultMaxCommitBatchSize),
30 debug_info_getter_(debug_info_getter), 31 debug_info_getter_(debug_info_getter),
31 traffic_recorder_(traffic_recorder), 32 traffic_recorder_(traffic_recorder),
32 keystore_encryption_enabled_(keystore_encryption_enabled), 33 keystore_encryption_enabled_(keystore_encryption_enabled),
33 invalidator_client_id_(invalidator_client_id), 34 invalidator_client_id_(invalidator_client_id),
34 server_enabled_pre_commit_update_avoidance_(false), 35 server_enabled_pre_commit_update_avoidance_(false),
35 client_enabled_pre_commit_update_avoidance_( 36 client_enabled_pre_commit_update_avoidance_(
36 client_enabled_pre_commit_update_avoidance) { 37 client_enabled_pre_commit_update_avoidance) {
37 for (size_t i = 0u; i < workers.size(); ++i) 38 for (size_t i = 0u; i < workers.size(); ++i)
38 workers_.push_back(workers[i]); 39 workers_.push_back(workers[i]);
39 40
40 std::vector<SyncEngineEventListener*>::const_iterator it; 41 std::vector<SyncEngineEventListener*>::const_iterator it;
41 for (it = listeners.begin(); it != listeners.end(); ++it) 42 for (it = listeners.begin(); it != listeners.end(); ++it)
42 listeners_.AddObserver(*it); 43 listeners_.AddObserver(*it);
43 } 44 }
44 45
45 SyncSessionContext::~SyncSessionContext() { 46 SyncSessionContext::~SyncSessionContext() {
46 } 47 }
47 48
48 void SyncSessionContext::set_routing_info( 49 void SyncSessionContext::set_routing_info(
49 const ModelSafeRoutingInfo& routing_info) { 50 const ModelSafeRoutingInfo& routing_info) {
50 routing_info_ = routing_info; 51 routing_info_ = routing_info;
51 52
52 // TODO(rlarocque): This is not a good long-term solution. We must find a 53 // TODO(rlarocque): This is not a good long-term solution. We must find a
53 // better way to initialize the set of CommitContributors. 54 // better way to initialize the set of CommitContributors and UpdateHandlers.
55 ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info);
56
54 STLDeleteValues<CommitContributorMap>(&commit_contributor_map_); 57 STLDeleteValues<CommitContributorMap>(&commit_contributor_map_);
55 ModelTypeSet enabled_types = GetRoutingInfoTypes(routing_info);
56 for (ModelTypeSet::Iterator it = enabled_types.First(); it.Good(); it.Inc()) { 58 for (ModelTypeSet::Iterator it = enabled_types.First(); it.Good(); it.Inc()) {
57 SyncDirectoryCommitContributor* contributor = 59 SyncDirectoryCommitContributor* contributor =
58 new SyncDirectoryCommitContributor(directory(), it.Get()); 60 new SyncDirectoryCommitContributor(directory(), it.Get());
59 commit_contributor_map_.insert(std::make_pair(it.Get(), contributor)); 61 commit_contributor_map_.insert(std::make_pair(it.Get(), contributor));
60 } 62 }
63
64 STLDeleteValues<UpdateHandlerMap>(&update_handler_map_);
65 for (ModelTypeSet::Iterator it = enabled_types.First(); it.Good(); it.Inc()) {
66 SyncDirectoryUpdateHandler* handler =
67 new SyncDirectoryUpdateHandler(directory(), it.Get());
68 update_handler_map_.insert(std::make_pair(it.Get(), handler));
69 }
61 } 70 }
62 71
63 } // namespace sessions 72 } // namespace sessions
64 } // namespace syncer 73 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/sessions/sync_session_context.h ('k') | sync/sync_core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698