summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/sessions
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 20:46:36 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 20:46:36 +0000
commit4a6d85644a21afb4d2bc10edf7808a23811b9004 (patch)
tree13b32e91ed3bc5cfe78f9349673707abc98ceb46 /chrome/browser/sync/sessions
parent590426ed28c056eb64e51bdea866d1934188c3fb (diff)
downloadchromium_src-4a6d85644a21afb4d2bc10edf7808a23811b9004.zip
chromium_src-4a6d85644a21afb4d2bc10edf7808a23811b9004.tar.gz
chromium_src-4a6d85644a21afb4d2bc10edf7808a23811b9004.tar.bz2
Revert 72685 - [SYNC] Refactor SyncSourceInfo and add support in chrome invalidation client and syncer thread for passing a datatype-specific payload originating in the invalidation server and directed at the sync frontend server. Also fixes bug with last_sync_time and PostTimeToTypeHistogram, which would get hit when the unit tests were being run.
BUG=68572,69558 TEST=unit Review URL: http://codereview.chromium.org/6182004 TBR=zea@chromium.org Review URL: http://codereview.chromium.org/6270006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/sessions')
-rw-r--r--chrome/browser/sync/sessions/sync_session.cc49
-rw-r--r--chrome/browser/sync/sessions/sync_session.h33
-rw-r--r--chrome/browser/sync/sessions/sync_session_unittest.cc59
3 files changed, 1 insertions, 140 deletions
diff --git a/chrome/browser/sync/sessions/sync_session.cc b/chrome/browser/sync/sessions/sync_session.cc
index c5876f9..077b629 100644
--- a/chrome/browser/sync/sessions/sync_session.cc
+++ b/chrome/browser/sync/sessions/sync_session.cc
@@ -9,53 +9,6 @@
namespace browser_sync {
namespace sessions {
-TypePayloadMap ModelTypeBitSetToTypePayloadMap(
- const syncable::ModelTypeBitSet& types,
- const std::string& payload) {
- TypePayloadMap types_with_payloads;
- for (size_t i = syncable::FIRST_REAL_MODEL_TYPE;
- i < types.size(); ++i) {
- if (types[i]) {
- types_with_payloads[syncable::ModelTypeFromInt(i)] = payload;
- }
- }
- return types_with_payloads;
-}
-
-TypePayloadMap RoutingInfoToTypePayloadMap(const ModelSafeRoutingInfo& routes,
- const std::string& payload) {
- TypePayloadMap types_with_payloads;
- for (ModelSafeRoutingInfo::const_iterator i = routes.begin();
- i != routes.end(); ++i) {
- types_with_payloads[i->first] = payload;
- }
- return types_with_payloads;
-}
-
-void CoalescePayloads(TypePayloadMap* original,
- const TypePayloadMap& update) {
- 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.
- (*original)[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.
- (*original)[i->first] = i->second;
- }
- }
-}
-
-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,
@@ -136,7 +89,7 @@ SyncSourceInfo SyncSession::TestAndSetSource() {
SyncSourceInfo old_source = source_;
source_ = SyncSourceInfo(
sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION,
- source_.types);
+ source_.second);
return old_source;
}
diff --git a/chrome/browser/sync/sessions/sync_session.h b/chrome/browser/sync/sessions/sync_session.h
index fb605f1..3626d11 100644
--- a/chrome/browser/sync/sessions/sync_session.h
+++ b/chrome/browser/sync/sessions/sync_session.h
@@ -15,20 +15,16 @@
#define CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_H_
#pragma once
-#include <map>
-#include <string>
#include <utility>
#include <vector>
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
-#include "chrome/browser/sync/engine/model_safe_worker.h"
#include "chrome/browser/sync/sessions/ordered_commit_set.h"
#include "chrome/browser/sync/sessions/session_state.h"
#include "chrome/browser/sync/sessions/status_controller.h"
#include "chrome/browser/sync/sessions/sync_session_context.h"
-#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/util/extensions_activity_monitor.h"
namespace syncable {
@@ -40,35 +36,6 @@ class ModelSafeWorker;
namespace sessions {
-// A container that contains a set of datatypes with possible string payloads.
-typedef std::map<syncable::ModelType, std::string> TypePayloadMap;
-
-// Helper utils for building TypePayloadMaps.
-// Convert a ModelTypeBitset into a TypePayloadMap using a default payload.
-TypePayloadMap ModelTypeBitSetToTypePayloadMap(
- const syncable::ModelTypeBitSet& types,
- const std::string& payload);
-// Convert a ModelSafeRoutingInfo into a TypePayloadMap using a default payload.
-TypePayloadMap RoutingInfoToTypePayloadMap(
- const ModelSafeRoutingInfo& routes,
- const std::string& payload);
-// Coalesce |update| into |original|, overwriting only when |update| has
-// a non-empty payload.
-void CoalescePayloads(TypePayloadMap* original, const TypePayloadMap& update);
-
-// A container for the source of a sync session. This includes the update
-// source, the datatypes triggering the sync session, and possible session
-// specific payloads which should be sent to the server.
-struct SyncSourceInfo {
- SyncSourceInfo();
- SyncSourceInfo(
- const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u,
- const TypePayloadMap& t);
-
- sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source;
- TypePayloadMap types;
-};
-
class SyncSession {
public:
// The Delegate services events that occur during the session requiring an
diff --git a/chrome/browser/sync/sessions/sync_session_unittest.cc b/chrome/browser/sync/sessions/sync_session_unittest.cc
index 57ea030..681c0ad 100644
--- a/chrome/browser/sync/sessions/sync_session_unittest.cc
+++ b/chrome/browser/sync/sessions/sync_session_unittest.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/sync/engine/syncer_types.h"
#include "chrome/browser/sync/engine/syncer_util.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
-#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/test/sync/engine/test_directory_setter_upper.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -253,64 +252,6 @@ TEST_F(SyncSessionTest, MoreToSyncIfConflictsResolved) {
EXPECT_TRUE(session_->HasMoreToSync());
}
-TEST_F(SyncSessionTest, ModelTypeBitSetToTypePayloadMap) {
- syncable::ModelTypeBitSet types;
- std::string payload = "test";
- TypePayloadMap types_with_payloads =
- ModelTypeBitSetToTypePayloadMap(types, payload);
- EXPECT_TRUE(types_with_payloads.empty());
-
- types[syncable::BOOKMARKS] = true;
- types[syncable::PASSWORDS] = true;
- types[syncable::AUTOFILL] = true;
- payload = "test2";
- types_with_payloads = ModelTypeBitSetToTypePayloadMap(types, payload);
-
- ASSERT_EQ(3U, types_with_payloads.size());
- EXPECT_EQ(types_with_payloads[syncable::BOOKMARKS], payload);
- EXPECT_EQ(types_with_payloads[syncable::PASSWORDS], payload);
- EXPECT_EQ(types_with_payloads[syncable::AUTOFILL], payload);
-}
-
-TEST_F(SyncSessionTest, RoutingInfoToTypePayloadMap) {
- std::string payload = "test";
- TypePayloadMap types_with_payloads
- = RoutingInfoToTypePayloadMap(routes_, payload);
- ASSERT_EQ(routes_.size(), types_with_payloads.size());
- for (ModelSafeRoutingInfo::iterator iter = routes_.begin();
- iter != routes_.end();
- ++iter) {
- EXPECT_EQ(payload, types_with_payloads[iter->first]);
- }
-}
-
-TEST_F(SyncSessionTest, CoalescePayloads) {
- TypePayloadMap original;
- std::string empty_payload;
- std::string payload1 = "payload1";
- std::string payload2 = "payload2";
- std::string payload3 = "payload3";
- original[syncable::BOOKMARKS] = empty_payload;
- original[syncable::PASSWORDS] = payload1;
- original[syncable::AUTOFILL] = payload2;
- original[syncable::THEMES] = payload3;
-
- TypePayloadMap update;
- update[syncable::BOOKMARKS] = empty_payload; // Same.
- update[syncable::PASSWORDS] = empty_payload; // Overwrite with empty.
- update[syncable::AUTOFILL] = payload1; // Overwrite with non-empty.
- update[syncable::SESSIONS] = payload2; // New.
- // Themes untouched.
-
- CoalescePayloads(&original, update);
- ASSERT_EQ(5U, original.size());
- EXPECT_EQ(empty_payload, original[syncable::BOOKMARKS]);
- EXPECT_EQ(payload1, original[syncable::PASSWORDS]);
- EXPECT_EQ(payload1, original[syncable::AUTOFILL]);
- EXPECT_EQ(payload2, original[syncable::SESSIONS]);
- EXPECT_EQ(payload3, original[syncable::THEMES]);
-}
-
TEST_F(SyncSessionTest, ResetTransientState) {
status()->update_conflicts_resolved(true);
status()->increment_num_successful_commits();