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

Side by Side Diff: chrome/browser/sync/sessions/sync_session.cc

Issue 6182004: [SYNC] Refactor SyncSourceInfo and add support in chrome invalidation client ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Added util functions Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/sync/sessions/sync_session.h" 5 #include "chrome/browser/sync/sessions/sync_session.h"
6 #include "chrome/browser/sync/syncable/directory_manager.h" 6 #include "chrome/browser/sync/syncable/directory_manager.h"
7 #include "chrome/browser/sync/syncable/model_type.h" 7 #include "chrome/browser/sync/syncable/model_type.h"
8 8
9 namespace browser_sync { 9 namespace browser_sync {
10 namespace sessions { 10 namespace sessions {
11 11
12 void BuildModelTypeMapFromModelTypeBitSet(
13 const syncable::ModelTypeBitSet& types,
14 const std::string& payload,
15 ModelTypeMap* map) {
16 DCHECK(map);
17 for (size_t i = syncable::FIRST_REAL_MODEL_TYPE;
18 i < types.size();
19 ++i) {
20 if (types[i]) {
21 (*map)[syncable::ModelTypeFromInt(i)] = payload;
22 }
23 }
24 }
25
26 void BuildModelTypeMapFromModelSafeRoutingInfo(
27 const ModelSafeRoutingInfo& routes,
28 const std::string& payload,
29 ModelTypeMap* map) {
30 DCHECK(map);
31 for (ModelSafeRoutingInfo::const_iterator i = routes.begin();
32 i != routes.end();
33 ++i) {
34 (*map)[i->first] = payload;
35 }
36 }
37
38 SyncSourceInfo::SyncSourceInfo()
39 : updates_source(sync_pb::GetUpdatesCallerInfo::UNKNOWN) {}
40
41 SyncSourceInfo::SyncSourceInfo(
42 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u,
43 const ModelTypeMap& t)
44 : updates_source(u), types(t) {}
45
12 SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate, 46 SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate,
13 SyncSourceInfo source, 47 SyncSourceInfo source,
14 const ModelSafeRoutingInfo& routing_info, 48 const ModelSafeRoutingInfo& routing_info,
15 const std::vector<ModelSafeWorker*>& workers) 49 const std::vector<ModelSafeWorker*>& workers)
16 : context_(context), 50 : context_(context),
17 source_(source), 51 source_(source),
18 write_transaction_(NULL), 52 write_transaction_(NULL),
19 delegate_(delegate), 53 delegate_(delegate),
20 workers_(workers), 54 workers_(workers),
21 routing_info_(routing_info) { 55 routing_info_(routing_info) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 delegate_->IsSyncingCurrentlySilenced(), 89 delegate_->IsSyncingCurrentlySilenced(),
56 status_controller_->unsynced_handles().size(), 90 status_controller_->unsynced_handles().size(),
57 status_controller_->TotalNumConflictingItems(), 91 status_controller_->TotalNumConflictingItems(),
58 status_controller_->did_commit_items()); 92 status_controller_->did_commit_items());
59 } 93 }
60 94
61 SyncSourceInfo SyncSession::TestAndSetSource() { 95 SyncSourceInfo SyncSession::TestAndSetSource() {
62 SyncSourceInfo old_source = source_; 96 SyncSourceInfo old_source = source_;
63 source_ = SyncSourceInfo( 97 source_ = SyncSourceInfo(
64 sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION, 98 sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION,
65 source_.second); 99 source_.types);
66 return old_source; 100 return old_source;
67 } 101 }
68 102
69 bool SyncSession::HasMoreToSync() const { 103 bool SyncSession::HasMoreToSync() const {
70 const StatusController* status = status_controller_.get(); 104 const StatusController* status = status_controller_.get();
71 return ((status->commit_ids().size() < status->unsynced_handles().size()) && 105 return ((status->commit_ids().size() < status->unsynced_handles().size()) &&
72 status->syncer_status().num_successful_commits > 0) || 106 status->syncer_status().num_successful_commits > 0) ||
73 status->conflict_sets_built() || 107 status->conflict_sets_built() ||
74 status->conflicts_resolved(); 108 status->conflicts_resolved();
75 // Or, we have conflicting updates, but we're making progress on 109 // Or, we have conflicting updates, but we're making progress on
76 // resolving them... 110 // resolving them...
77 } 111 }
78 112
79 } // namespace sessions 113 } // namespace sessions
80 } // namespace browser_sync 114 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698