diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 01:41:42 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 01:41:42 +0000 |
commit | 0a6e9612034484c5340d6d0f55169c1287c18588 (patch) | |
tree | bc4b59868f8609e7c6cfc95e99a4e648d6163d13 /sync/internal_api/public/sessions | |
parent | 7c97bc24bc91ee5ba25296a11e88ad2dd574829c (diff) | |
download | chromium_src-0a6e9612034484c5340d6d0f55169c1287c18588.zip chromium_src-0a6e9612034484c5340d6d0f55169c1287c18588.tar.gz chromium_src-0a6e9612034484c5340d6d0f55169c1287c18588.tar.bz2 |
sync: Remove SyncSourceInfo
The SyncSourceInfo was a struct that contained a GetUpdatesSource and a
ModelTypeInvalidationMap. Both of these types are in the process of
being deprecated. The SyncSourceInfo itself was used only for debugging
(about:sync), tests (mostly sync_scheduler_unittest.cc) and maintaining
compatibility with some old function signatures.
Removing the SyncSourceInfo allow us to remove dependencies on
ModelTypeInvalidationMap, which is a step towards enabling invalidation
"trickles" support.
BUG=233437
Review URL: https://chromiumcodereview.appspot.com/19982002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/public/sessions')
7 files changed, 24 insertions, 139 deletions
diff --git a/sync/internal_api/public/sessions/model_neutral_state.h b/sync/internal_api/public/sessions/model_neutral_state.h index e61e995..4abf158 100644 --- a/sync/internal_api/public/sessions/model_neutral_state.h +++ b/sync/internal_api/public/sessions/model_neutral_state.h @@ -26,6 +26,9 @@ struct SYNC_EXPORT ModelNeutralState { // requested_update_types stores the set of types which were requested. ModelTypeSet updates_request_types; + // The set of types for which commits were sent to the server. + ModelTypeSet commit_request_types; + sync_pb::ClientToServerResponse updates_response; int num_successful_commits; diff --git a/sync/internal_api/public/sessions/sync_session_snapshot.cc b/sync/internal_api/public/sessions/sync_session_snapshot.cc index 03da223..97bc094 100644 --- a/sync/internal_api/public/sessions/sync_session_snapshot.cc +++ b/sync/internal_api/public/sessions/sync_session_snapshot.cc @@ -7,6 +7,7 @@ #include "base/json/json_writer.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" +#include "sync/protocol/proto_enum_conversions.h" namespace syncer { namespace sessions { @@ -30,24 +31,24 @@ SyncSessionSnapshot::SyncSessionSnapshot( int num_encryption_conflicts, int num_hierarchy_conflicts, int num_server_conflicts, - const SyncSourceInfo& source, bool notifications_enabled, size_t num_entries, base::Time sync_start_time, const std::vector<int>& num_entries_by_type, - const std::vector<int>& num_to_delete_entries_by_type) + const std::vector<int>& num_to_delete_entries_by_type, + sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source) : model_neutral_state_(model_neutral_state), download_progress_markers_(download_progress_markers), is_silenced_(is_silenced), num_encryption_conflicts_(num_encryption_conflicts), num_hierarchy_conflicts_(num_hierarchy_conflicts), num_server_conflicts_(num_server_conflicts), - source_(source), notifications_enabled_(notifications_enabled), num_entries_(num_entries), sync_start_time_(sync_start_time), num_entries_by_type_(num_entries_by_type), num_to_delete_entries_by_type_(num_to_delete_entries_by_type), + legacy_updates_source_(legacy_updates_source), is_initialized_(true) { } @@ -83,7 +84,8 @@ base::DictionaryValue* SyncSessionSnapshot::ToValue() const { value->SetInteger("numServerConflicts", num_server_conflicts_); value->SetInteger("numEntries", num_entries_); - value->Set("source", source_.ToValue()); + value->SetString("legacySource", + GetUpdatesSourceString(legacy_updates_source_)); value->SetBoolean("notificationsEnabled", notifications_enabled_); scoped_ptr<base::DictionaryValue> counter_entries( @@ -135,10 +137,6 @@ int SyncSessionSnapshot::num_server_conflicts() const { return num_server_conflicts_; } -SyncSourceInfo SyncSessionSnapshot::source() const { - return source_; -} - bool SyncSessionSnapshot::notifications_enabled() const { return notifications_enabled_; } @@ -164,5 +162,10 @@ SyncSessionSnapshot::num_to_delete_entries_by_type() const { return num_to_delete_entries_by_type_; } +sync_pb::GetUpdatesCallerInfo::GetUpdatesSource +SyncSessionSnapshot::legacy_updates_source() const { + return legacy_updates_source_; +} + } // namespace sessions } // namespace syncer diff --git a/sync/internal_api/public/sessions/sync_session_snapshot.h b/sync/internal_api/public/sessions/sync_session_snapshot.h index e1053ad..97a97aa 100644 --- a/sync/internal_api/public/sessions/sync_session_snapshot.h +++ b/sync/internal_api/public/sessions/sync_session_snapshot.h @@ -13,7 +13,6 @@ #include "sync/internal_api/public/base/model_type.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" namespace base { class DictionaryValue; @@ -37,12 +36,12 @@ class SYNC_EXPORT SyncSessionSnapshot { int num_encryption_conflicts, int num_hierarchy_conflicts, int num_server_conflicts, - const SyncSourceInfo& source, bool notifications_enabled, size_t num_entries, base::Time sync_start_time, const std::vector<int>& num_entries_by_type, - const std::vector<int>& num_to_delete_entries_by_type); + const std::vector<int>& num_to_delete_entries_by_type, + sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source); ~SyncSessionSnapshot(); // Caller takes ownership of the returned dictionary. @@ -59,12 +58,12 @@ class SYNC_EXPORT SyncSessionSnapshot { int num_encryption_conflicts() const; int num_hierarchy_conflicts() const; int num_server_conflicts() const; - SyncSourceInfo source() const; bool notifications_enabled() const; size_t num_entries() const; base::Time sync_start_time() const; const std::vector<int>& num_entries_by_type() const; const std::vector<int>& num_to_delete_entries_by_type() const; + sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source() const; // Set iff this snapshot was not built using the default constructor. bool is_initialized() const; @@ -76,7 +75,6 @@ class SYNC_EXPORT SyncSessionSnapshot { int num_encryption_conflicts_; int num_hierarchy_conflicts_; int num_server_conflicts_; - SyncSourceInfo source_; bool notifications_enabled_; size_t num_entries_; base::Time sync_start_time_; @@ -84,6 +82,11 @@ class SYNC_EXPORT SyncSessionSnapshot { std::vector<int> num_entries_by_type_; std::vector<int> num_to_delete_entries_by_type_; + // This enum value used to be an important part of the sync protocol, but is + // now deprecated. We continue to use it in the snapshot because there is + // still some value in displaying it on the about:sync page. + sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source_; + bool is_initialized_; }; diff --git a/sync/internal_api/public/sessions/sync_session_snapshot_unittest.cc b/sync/internal_api/public/sessions/sync_session_snapshot_unittest.cc index 36056e3..881ab01 100644 --- a/sync/internal_api/public/sessions/sync_session_snapshot_unittest.cc +++ b/sync/internal_api/public/sessions/sync_session_snapshot_unittest.cc @@ -7,7 +7,6 @@ #include "base/memory/scoped_ptr.h" #include "base/test/values_test_util.h" #include "base/values.h" -#include "sync/internal_api/public/sessions/sync_source_info.h" #include "testing/gtest/include/gtest/gtest.h" namespace syncer { @@ -44,21 +43,18 @@ TEST_F(SyncSessionSnapshotTest, SyncSessionSnapshotToValue) { const int kNumHierarchyConflicts = 1055; const int kNumServerConflicts = 1057; - SyncSourceInfo source; - scoped_ptr<base::DictionaryValue> expected_source_value(source.ToValue()); - SyncSessionSnapshot snapshot(model_neutral, download_progress_markers, kIsSilenced, kNumEncryptionConflicts, kNumHierarchyConflicts, kNumServerConflicts, - source, false, 0, base::Time::Now(), std::vector<int>(MODEL_TYPE_COUNT,0), - std::vector<int>(MODEL_TYPE_COUNT, 0)); + std::vector<int>(MODEL_TYPE_COUNT, 0), + sync_pb::GetUpdatesCallerInfo::UNKNOWN); scoped_ptr<base::DictionaryValue> value(snapshot.ToValue()); EXPECT_EQ(17u, value->size()); ExpectDictIntegerValue(model_neutral.num_successful_commits, @@ -86,7 +82,6 @@ TEST_F(SyncSessionSnapshotTest, SyncSessionSnapshotToValue) { "numHierarchyConflicts"); ExpectDictIntegerValue(kNumServerConflicts, *value, "numServerConflicts"); - ExpectDictDictionaryValue(*expected_source_value, *value, "source"); ExpectDictBooleanValue(false, *value, "notificationsEnabled"); } diff --git a/sync/internal_api/public/sessions/sync_source_info.cc b/sync/internal_api/public/sessions/sync_source_info.cc deleted file mode 100644 index 5c05de6..0000000 --- a/sync/internal_api/public/sessions/sync_source_info.cc +++ /dev/null @@ -1,35 +0,0 @@ -// 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/sessions/sync_source_info.h" - -#include "base/values.h" -#include "sync/protocol/proto_enum_conversions.h" - -namespace syncer { -namespace sessions { - -SyncSourceInfo::SyncSourceInfo() - : updates_source(sync_pb::GetUpdatesCallerInfo::UNKNOWN) {} - -SyncSourceInfo::SyncSourceInfo(const ModelTypeInvalidationMap& t) - : updates_source(sync_pb::GetUpdatesCallerInfo::UNKNOWN), types(t) {} - -SyncSourceInfo::SyncSourceInfo( - const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u, - const ModelTypeInvalidationMap& t) - : updates_source(u), types(t) {} - -SyncSourceInfo::~SyncSourceInfo() {} - -base::DictionaryValue* SyncSourceInfo::ToValue() const { - base::DictionaryValue* value = new base::DictionaryValue(); - value->SetString("updatesSource", - GetUpdatesSourceString(updates_source)); - value->Set("types", ModelTypeInvalidationMapToValue(types)); - return value; -} - -} // namespace sessions -} // namespace syncer diff --git a/sync/internal_api/public/sessions/sync_source_info.h b/sync/internal_api/public/sessions/sync_source_info.h deleted file mode 100644 index f41727b..0000000 --- a/sync/internal_api/public/sessions/sync_source_info.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 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. - -#ifndef SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SOURCE_INFO_H_ -#define SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SOURCE_INFO_H_ - -#include "base/basictypes.h" -#include "sync/base/sync_export.h" -#include "sync/internal_api/public/base/model_type.h" -#include "sync/internal_api/public/base/model_type_invalidation_map.h" -#include "sync/protocol/sync.pb.h" - -namespace base { -class DictionaryValue; -} - -namespace syncer { -namespace sessions { - -// 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 SYNC_EXPORT SyncSourceInfo { - SyncSourceInfo(); - explicit SyncSourceInfo(const ModelTypeInvalidationMap& t); - SyncSourceInfo( - const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u, - const ModelTypeInvalidationMap& t); - ~SyncSourceInfo(); - - // Caller takes ownership of the returned dictionary. - base::DictionaryValue* ToValue() const; - - sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source; - ModelTypeInvalidationMap types; -}; - -} // namespace sessions -} // namespace syncer - -#endif // SYNC_INTERNAL_API_PUBLIC_SESSIONS_SYNC_SOURCE_INFO_H_ diff --git a/sync/internal_api/public/sessions/sync_source_info_unittest.cc b/sync/internal_api/public/sessions/sync_source_info_unittest.cc deleted file mode 100644 index cbdecf17..0000000 --- a/sync/internal_api/public/sessions/sync_source_info_unittest.cc +++ /dev/null @@ -1,42 +0,0 @@ -// 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/sessions/sync_source_info.h" - -#include "base/test/values_test_util.h" -#include "base/values.h" -#include "sync/internal_api/public/base/model_type.h" -#include "sync/internal_api/public/base/model_type_invalidation_map.h" -#include "sync/protocol/sync.pb.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace syncer { -namespace sessions { -namespace { - -using base::ExpectDictDictionaryValue; -using base::ExpectDictStringValue; - -class SyncSourceInfoTest : public testing::Test {}; - -TEST_F(SyncSourceInfoTest, SyncSourceInfoToValue) { - sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source = - sync_pb::GetUpdatesCallerInfo::PERIODIC; - ModelTypeInvalidationMap types; - types[PREFERENCES].payload = "preferencespayload"; - types[EXTENSIONS].payload = ""; - scoped_ptr<base::DictionaryValue> expected_types_value( - ModelTypeInvalidationMapToValue(types)); - - SyncSourceInfo source_info(updates_source, types); - - scoped_ptr<base::DictionaryValue> value(source_info.ToValue()); - EXPECT_EQ(2u, value->size()); - ExpectDictStringValue("PERIODIC", *value, "updatesSource"); - ExpectDictDictionaryValue(*expected_types_value, *value, "types"); -} - -} // namespace syncer -} // namespace sessions -} // namespace |