Index: chrome/browser/sync/sessions/sync_session.cc |
=================================================================== |
--- chrome/browser/sync/sessions/sync_session.cc (revision 71618) |
+++ chrome/browser/sync/sessions/sync_session.cc (working copy) |
@@ -2,6 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "chrome/browser/sync/engine/model_safe_worker.h" |
akalin
2011/01/26 01:15:17
move this to the .h file
Nicolas Zea
2011/01/26 01:41:28
Done.
|
#include "chrome/browser/sync/sessions/sync_session.h" |
#include "chrome/browser/sync/syncable/directory_manager.h" |
#include "chrome/browser/sync/syncable/model_type.h" |
@@ -9,6 +10,58 @@ |
namespace browser_sync { |
namespace sessions { |
+TypePayloadMap ModelTypeBitSetToTypePayloadMap( |
+ const syncable::ModelTypeBitSet& types, |
+ const std::string& payload) { |
+ TypePayloadMap map; |
+ for (size_t i = syncable::FIRST_REAL_MODEL_TYPE; |
+ i < types.size(); |
+ ++i) { |
akalin
2011/01/26 01:15:17
this can go on previous line
Nicolas Zea
2011/01/26 01:41:28
Done.
|
+ if (types[i]) { |
+ map[syncable::ModelTypeFromInt(i)] = payload; |
+ } |
+ } |
+ return map; |
+} |
+ |
+TypePayloadMap RoutingInfoToTypePayloadMap(const ModelSafeRoutingInfo& routes, |
+ const std::string& payload) { |
+ TypePayloadMap map; |
+ for (ModelSafeRoutingInfo::const_iterator i = routes.begin(); |
+ i != routes.end(); |
+ ++i) { |
akalin
2011/01/26 01:15:17
so can this
Nicolas Zea
2011/01/26 01:41:28
Done.
|
+ map[i->first] = payload; |
+ } |
+ return map; |
+} |
+ |
+TypePayloadMap CoalescePayloads(const TypePayloadMap& original, |
+ const TypePayloadMap& update) { |
+ TypePayloadMap new_map = original; |
+ for (TypePayloadMap::const_iterator i = update.begin(); |
+ i != update.end(); |
+ ++i) { |
+ if (original.count(i->first) == 0) { |
+ // If this datatype isn't already in our map, add it with whatever payload |
+ // it has. |
+ new_map[i->first] = i->second; |
+ } else if (i->second.length() > 0) { |
+ // If this datatype is already in our map, we only overwrite the payload |
+ // if the new one is non-empty. |
+ new_map[i->first] = i->second; |
+ } |
+ } |
+ return new_map; |
+} |
+ |
+SyncSourceInfo::SyncSourceInfo() |
+ : updates_source(sync_pb::GetUpdatesCallerInfo::UNKNOWN) {} |
+ |
+SyncSourceInfo::SyncSourceInfo( |
+ const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u, |
+ const TypePayloadMap& t) |
+ : updates_source(u), types(t) {} |
+ |
SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate, |
SyncSourceInfo source, |
const ModelSafeRoutingInfo& routing_info, |
@@ -62,7 +115,7 @@ |
SyncSourceInfo old_source = source_; |
source_ = SyncSourceInfo( |
sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION, |
- source_.second); |
+ source_.types); |
return old_source; |
} |