summaryrefslogtreecommitdiffstats
path: root/sync/internal_api/public
diff options
context:
space:
mode:
authormmontgomery@chromium.org <mmontgomery@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-15 19:18:15 +0000
committermmontgomery@chromium.org <mmontgomery@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-15 19:18:15 +0000
commitb2565823ffd83289eb2d092bb3f4db877a50408e (patch)
tree7d72f181e951e69a394d83d911f8a3c583335b89 /sync/internal_api/public
parent8969385b1fc69d8077083bb92ba4b595210f5696 (diff)
downloadchromium_src-b2565823ffd83289eb2d092bb3f4db877a50408e.zip
chromium_src-b2565823ffd83289eb2d092bb3f4db877a50408e.tar.gz
chromium_src-b2565823ffd83289eb2d092bb3f4db877a50408e.tar.bz2
[sync] Refactor SyncSessionSnapshot to use new ProgressMarkerMap.
This is the first step in refactoring the Sync integration tests to use progress markers to detect quiescence. This will save that mechanism from having to round-trip progress markers through multiple encodings. We can instead use protobufs' existing serialization/deserialization methods. BUG= Review URL: https://chromiumcodereview.appspot.com/10986004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/public')
-rw-r--r--sync/internal_api/public/base/progress_marker_map.cc27
-rw-r--r--sync/internal_api/public/base/progress_marker_map.h35
-rw-r--r--sync/internal_api/public/sessions/sync_session_snapshot.cc8
-rw-r--r--sync/internal_api/public/sessions/sync_session_snapshot.h8
4 files changed, 70 insertions, 8 deletions
diff --git a/sync/internal_api/public/base/progress_marker_map.cc b/sync/internal_api/public/base/progress_marker_map.cc
new file mode 100644
index 0000000..20d7ea3
--- /dev/null
+++ b/sync/internal_api/public/base/progress_marker_map.cc
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/internal_api/public/base/progress_marker_map.h"
+
+#include "base/json/json_writer.h"
+#include "base/json/string_escape.h"
+#include "base/values.h"
+
+namespace syncer {
+
+scoped_ptr<DictionaryValue> ProgressMarkerMapToValue(
+ const ProgressMarkerMap& marker_map) {
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
+ for (ProgressMarkerMap::const_iterator it = marker_map.begin();
+ it != marker_map.end(); ++it) {
+ std::string printable_payload;
+ base::JsonDoubleQuote(it->second,
+ false /* put_in_quotes */,
+ &printable_payload);
+ value->SetString(ModelTypeToString(it->first), printable_payload);
+ }
+ return value.Pass();
+}
+
+} // namespace syncer
diff --git a/sync/internal_api/public/base/progress_marker_map.h b/sync/internal_api/public/base/progress_marker_map.h
new file mode 100644
index 0000000..7091ca1
--- /dev/null
+++ b/sync/internal_api/public/base/progress_marker_map.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Definition of ProgressMarkerMap and various utility functions.
+
+#ifndef SYNC_INTERNAL_PUBLIC_API_BASE_PROGRESS_MARKER_MAP_H_
+#define SYNC_INTERNAL_PUBLIC_API_BASE_PROGRESS_MARKER_MAP_H_
+
+#include <map>
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "sync/base/sync_export.h"
+#include "sync/internal_api/public/base/model_type.h"
+
+// TODO(akalin,mmontgomery): Move the non-exported functions in this file to a
+// private header.
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace syncer {
+
+// A container that maps ModelType to serialized
+// DataTypeProgressMarkers.
+typedef std::map<ModelType, std::string> ProgressMarkerMap;
+
+scoped_ptr<base::DictionaryValue> ProgressMarkerMapToValue(
+ const ProgressMarkerMap& marker_map);
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_PUBLIC_API_BASE_PROGRESS_MARKER_MAP_H_
diff --git a/sync/internal_api/public/sessions/sync_session_snapshot.cc b/sync/internal_api/public/sessions/sync_session_snapshot.cc
index 15e8893..0f6fb01 100644
--- a/sync/internal_api/public/sessions/sync_session_snapshot.cc
+++ b/sync/internal_api/public/sessions/sync_session_snapshot.cc
@@ -29,7 +29,7 @@ SyncSessionSnapshot::SyncSessionSnapshot(
const ModelNeutralState& model_neutral_state,
bool is_share_usable,
ModelTypeSet initial_sync_ended,
- const ModelTypeInvalidationMap& download_progress_markers,
+ const ProgressMarkerMap& download_progress_markers,
bool more_to_sync,
bool is_silenced,
int num_encryption_conflicts,
@@ -84,7 +84,7 @@ DictionaryValue* SyncSessionSnapshot::ToValue() const {
value->Set("initialSyncEnded",
ModelTypeSetToValue(initial_sync_ended_));
value->Set("downloadProgressMarkers",
- ModelTypeInvalidationMapToValue(download_progress_markers_));
+ ProgressMarkerMapToValue(download_progress_markers_).release());
value->SetBoolean("hasMoreToSync", has_more_to_sync_);
value->SetBoolean("isSilenced", is_silenced_);
// We don't care too much if we lose precision here, also.
@@ -123,8 +123,8 @@ ModelTypeSet SyncSessionSnapshot::initial_sync_ended() const {
return initial_sync_ended_;
}
-ModelTypeInvalidationMap
-SyncSessionSnapshot::download_progress_markers() const {
+const ProgressMarkerMap&
+ SyncSessionSnapshot::download_progress_markers() const {
return download_progress_markers_;
}
diff --git a/sync/internal_api/public/sessions/sync_session_snapshot.h b/sync/internal_api/public/sessions/sync_session_snapshot.h
index 1cc250f..16b0753 100644
--- a/sync/internal_api/public/sessions/sync_session_snapshot.h
+++ b/sync/internal_api/public/sessions/sync_session_snapshot.h
@@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/time.h"
#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base/model_type_invalidation_map.h"
+#include "sync/internal_api/public/base/progress_marker_map.h"
#include "sync/internal_api/public/sessions/model_neutral_state.h"
#include "sync/internal_api/public/sessions/sync_source_info.h"
@@ -33,7 +33,7 @@ class SyncSessionSnapshot {
const ModelNeutralState& model_neutral_state,
bool is_share_usable,
ModelTypeSet initial_sync_ended,
- const ModelTypeInvalidationMap& download_progress_markers,
+ const ProgressMarkerMap& download_progress_markers,
bool more_to_sync,
bool is_silenced,
int num_encryption_conflicts,
@@ -58,7 +58,7 @@ class SyncSessionSnapshot {
int64 num_server_changes_remaining() const;
bool is_share_usable() const;
ModelTypeSet initial_sync_ended() const;
- ModelTypeInvalidationMap download_progress_markers() const;
+ const ProgressMarkerMap& download_progress_markers() const;
bool has_more_to_sync() const;
bool is_silenced() const;
int num_encryption_conflicts() const;
@@ -78,7 +78,7 @@ class SyncSessionSnapshot {
ModelNeutralState model_neutral_state_;
bool is_share_usable_;
ModelTypeSet initial_sync_ended_;
- ModelTypeInvalidationMap download_progress_markers_;
+ ProgressMarkerMap download_progress_markers_;
bool has_more_to_sync_;
bool is_silenced_;
int num_encryption_conflicts_;