summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskym <skym@chromium.org>2015-12-01 09:57:36 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-01 17:58:40 +0000
commite740bd4b6bc9ed9e2e607026c2fbc3ca4091ad5c (patch)
treeaa50845af3609ceefc9b3641e8cc52bf082c6580
parent7652b1ef26c36c9c9badcc5539568d9e1539befe (diff)
downloadchromium_src-e740bd4b6bc9ed9e2e607026c2fbc3ca4091ad5c.zip
chromium_src-e740bd4b6bc9ed9e2e607026c2fbc3ca4091ad5c.tar.gz
chromium_src-e740bd4b6bc9ed9e2e607026c2fbc3ca4091ad5c.tar.bz2
[Sync] Renaming MetadataChanges to MetadataChangeList, slight metadata ownership tweak, and adding a few stub methods.
BUG=543405 Review URL: https://codereview.chromium.org/1478593002 Cr-Commit-Position: refs/heads/master@{#362450}
-rw-r--r--components/sync_driver/device_info_service.cc10
-rw-r--r--components/sync_driver/device_info_service.h7
-rw-r--r--sync/BUILD.gn8
-rw-r--r--sync/api/data_batch.h2
-rw-r--r--sync/api/metadata_batch.h2
-rw-r--r--sync/api/metadata_change_list.h (renamed from sync/api/metadata_changes.h)12
-rw-r--r--sync/api/model_type_change_processor.h6
-rw-r--r--sync/api/model_type_service.h11
-rw-r--r--sync/internal_api/public/fully_serialized_metadata_batch.cc20
-rw-r--r--sync/internal_api/public/fully_serialized_metadata_batch.h32
-rw-r--r--sync/internal_api/public/shared_model_type_processor.h4
-rw-r--r--sync/internal_api/public/simple_metadata_change_list.cc19
-rw-r--r--sync/internal_api/public/simple_metadata_change_list.h31
-rw-r--r--sync/internal_api/public/specifics_only_data_batch.cc15
-rw-r--r--sync/internal_api/public/specifics_only_data_batch.h29
-rw-r--r--sync/internal_api/shared_model_type_processor.cc16
-rw-r--r--sync/sync.gyp8
17 files changed, 196 insertions, 36 deletions
diff --git a/components/sync_driver/device_info_service.cc b/components/sync_driver/device_info_service.cc
index f210b2f..0a5949e 100644
--- a/components/sync_driver/device_info_service.cc
+++ b/components/sync_driver/device_info_service.cc
@@ -34,20 +34,20 @@ DeviceInfoService::DeviceInfoService(
DeviceInfoService::~DeviceInfoService() {}
-syncer_v2::MetadataChanges* DeviceInfoService::CreateMetadataChanges() {
- // TODO(skym): Implementation.
- return nullptr;
+scoped_ptr<syncer_v2::MetadataChangeList>
+DeviceInfoService::CreateMetadataChangeList() {
+ return make_scoped_ptr(new syncer_v2::SimpleMetadataChangeList());
}
syncer::SyncError DeviceInfoService::MergeSyncData(
- syncer_v2::MetadataChanges* metadata_changes,
+ scoped_ptr<syncer_v2::MetadataChangeList> metadata_change_list,
syncer_v2::EntityDataList entity_data_list) {
// TODO(skym): Implementation.
return syncer::SyncError();
}
syncer::SyncError DeviceInfoService::ApplySyncChanges(
- syncer_v2::MetadataChanges* metadata_changes,
+ scoped_ptr<syncer_v2::MetadataChangeList> metadata_change_list,
syncer_v2::EntityChangeList entity_changes) {
// TODO(skym): Implementation.
return syncer::SyncError();
diff --git a/components/sync_driver/device_info_service.h b/components/sync_driver/device_info_service.h
index 76a4126..fdd1127 100644
--- a/components/sync_driver/device_info_service.h
+++ b/components/sync_driver/device_info_service.h
@@ -15,6 +15,7 @@
#include "components/sync_driver/device_info_tracker.h"
#include "components/sync_driver/local_device_info_provider.h"
#include "sync/api/model_type_service.h"
+#include "sync/internal_api/public/simple_metadata_change_list.h"
namespace syncer {
class SyncError;
@@ -41,12 +42,12 @@ class DeviceInfoService : public syncer_v2::ModelTypeService,
~DeviceInfoService() override;
// ModelTypeService implementation.
- syncer_v2::MetadataChanges* CreateMetadataChanges() override;
+ scoped_ptr<syncer_v2::MetadataChangeList> CreateMetadataChangeList() override;
syncer::SyncError MergeSyncData(
- syncer_v2::MetadataChanges* metadata_changes,
+ scoped_ptr<syncer_v2::MetadataChangeList> metadata_change_list,
syncer_v2::EntityDataList entity_data_list) override;
syncer::SyncError ApplySyncChanges(
- syncer_v2::MetadataChanges* metadata_changes,
+ scoped_ptr<syncer_v2::MetadataChangeList> metadata_change_list,
syncer_v2::EntityChangeList entity_changes) override;
void LoadMetadata(MetadataCallback callback) override;
void GetData(ClientKeyList client_keys, DataCallback callback) override;
diff --git a/sync/BUILD.gn b/sync/BUILD.gn
index c6fd22b..d4d89d1 100644
--- a/sync/BUILD.gn
+++ b/sync/BUILD.gn
@@ -32,7 +32,7 @@ source_set("sync_core") {
"api/entity_data.cc",
"api/entity_data.h",
"api/metadata_batch.h",
- "api/metadata_changes.h",
+ "api/metadata_change_list.h",
"api/model_type_change_processor.cc",
"api/model_type_change_processor.h",
"api/model_type_service.cc",
@@ -235,6 +235,8 @@ source_set("sync_core") {
"internal_api/public/events/normal_get_updates_request_event.h",
"internal_api/public/events/poll_get_updates_request_event.h",
"internal_api/public/events/protocol_event.h",
+ "internal_api/public/fully_serialized_metadata_batch.cc",
+ "internal_api/public/fully_serialized_metadata_batch.h",
"internal_api/public/http_bridge.h",
"internal_api/public/http_bridge_network_resources.h",
"internal_api/public/http_post_provider_factory.h",
@@ -264,6 +266,10 @@ source_set("sync_core") {
"internal_api/public/sessions/update_counters.h",
"internal_api/public/shared_model_type_processor.h",
"internal_api/public/shutdown_reason.h",
+ "internal_api/public/simple_metadata_change_list.cc",
+ "internal_api/public/simple_metadata_change_list.h",
+ "internal_api/public/specifics_only_data_batch.cc",
+ "internal_api/public/specifics_only_data_batch.h",
"internal_api/public/sync_auth_provider.h",
"internal_api/public/sync_context.h",
"internal_api/public/sync_context_proxy.h",
diff --git a/sync/api/data_batch.h b/sync/api/data_batch.h
index 63359cf..f66b5960 100644
--- a/sync/api/data_batch.h
+++ b/sync/api/data_batch.h
@@ -9,7 +9,7 @@
namespace syncer_v2 {
-// Interface used by the processor and service to communicate about data.
+// Interface used by the processor to read data requested from the service.
class SYNC_EXPORT DataBatch {
public:
DataBatch() {}
diff --git a/sync/api/metadata_batch.h b/sync/api/metadata_batch.h
index 56ffffb..459999c 100644
--- a/sync/api/metadata_batch.h
+++ b/sync/api/metadata_batch.h
@@ -9,7 +9,7 @@
namespace syncer_v2 {
-// Interface used by the processor and service to communicate about metadata.
+// Interface used by the processor to read metadata requested from the service.
class SYNC_EXPORT MetadataBatch {
public:
MetadataBatch() {}
diff --git a/sync/api/metadata_changes.h b/sync/api/metadata_change_list.h
index a3d4d3b..e4435a8 100644
--- a/sync/api/metadata_changes.h
+++ b/sync/api/metadata_change_list.h
@@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef SYNC_API_METADATA_CHANGES_H_
-#define SYNC_API_METADATA_CHANGES_H_
+#ifndef SYNC_API_METADATA_CHANGE_LIST_H_
+#define SYNC_API_METADATA_CHANGE_LIST_H_
#include "sync/base/sync_export.h"
namespace syncer_v2 {
// Interface used by the processor and service to communicate about metadata.
-class SYNC_EXPORT MetadataChanges {
+class SYNC_EXPORT MetadataChangeList {
public:
- MetadataChanges() {}
- virtual ~MetadataChanges() {}
+ MetadataChangeList() {}
+ virtual ~MetadataChangeList() {}
};
} // namespace syncer_v2
-#endif // SYNC_API_METADATA_CHANGES_H_
+#endif // SYNC_API_METADATA_CHANGE_LIST_H_
diff --git a/sync/api/model_type_change_processor.h b/sync/api/model_type_change_processor.h
index 7781a0e..70874b3 100644
--- a/sync/api/model_type_change_processor.h
+++ b/sync/api/model_type_change_processor.h
@@ -17,7 +17,7 @@ class SyncError;
namespace syncer_v2 {
-class MetadataChanges;
+class MetadataChangeList;
// Interface used by the ModelTypeService to inform sync of local
// changes.
@@ -30,11 +30,11 @@ class SYNC_EXPORT ModelTypeChangeProcessor {
virtual void Put(const std::string& client_key,
const std::string& non_unique_name,
const sync_pb::EntitySpecifics& specifics,
- MetadataChanges* metadata_changes) = 0;
+ MetadataChangeList* metadata_change_list) = 0;
// Inform the processor of a deleted entity.
virtual void Delete(const std::string& client_key,
- MetadataChanges* metadata_changes) = 0;
+ MetadataChangeList* metadata_change_list) = 0;
};
} // namespace syncer_v2
diff --git a/sync/api/model_type_service.h b/sync/api/model_type_service.h
index c09271b..aa798f5 100644
--- a/sync/api/model_type_service.h
+++ b/sync/api/model_type_service.h
@@ -23,7 +23,7 @@ namespace syncer_v2 {
class DataBatch;
class MetadataBatch;
-class MetadataChanges;
+class MetadataChangeList;
// Interface implemented by model types to receive updates from sync via the
// SharedModelTypeProcessor. Provides a way for sync to update the data and
@@ -42,16 +42,17 @@ class SYNC_EXPORT ModelTypeService {
// Creates an object used to communicate changes in the sync metadata to the
// model type store.
- virtual MetadataChanges* CreateMetadataChanges() = 0;
+ virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0;
// Perform the initial merge of data from the sync server. Should only need
// to be called when sync is first turned on, not on every restart.
- virtual syncer::SyncError MergeSyncData(MetadataChanges* metadata_changes,
- EntityDataList entity_data_list) = 0;
+ virtual syncer::SyncError MergeSyncData(
+ scoped_ptr<MetadataChangeList> metadata_change_list,
+ EntityDataList entity_data_list) = 0;
// Apply changes from the sync server locally.
virtual syncer::SyncError ApplySyncChanges(
- MetadataChanges* metadata_changes,
+ scoped_ptr<MetadataChangeList> metadata_change_list,
EntityChangeList entity_changes) = 0;
// Asynchronously retrieve the sync metadata.
diff --git a/sync/internal_api/public/fully_serialized_metadata_batch.cc b/sync/internal_api/public/fully_serialized_metadata_batch.cc
new file mode 100644
index 0000000..820bdeb
--- /dev/null
+++ b/sync/internal_api/public/fully_serialized_metadata_batch.cc
@@ -0,0 +1,20 @@
+// Copyright 2015 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/fully_serialized_metadata_batch.h"
+
+namespace syncer_v2 {
+
+void FullySerializedMetadataBatch::PutMetadata(
+ const std::string& client_key,
+ const std::string& serialized_metadata) {
+ // TODO(skym): Implementation.
+}
+
+void FullySerializedMetadataBatch::PutGlobalMetadata(
+ const std::string& serialized_global_metadata) {
+ // TODO(skym): Implementation.
+}
+
+} // namespace syncer_v2
diff --git a/sync/internal_api/public/fully_serialized_metadata_batch.h b/sync/internal_api/public/fully_serialized_metadata_batch.h
new file mode 100644
index 0000000..9982024
--- /dev/null
+++ b/sync/internal_api/public/fully_serialized_metadata_batch.h
@@ -0,0 +1,32 @@
+// Copyright 2015 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_FULLY_SERIALIZED_METADATA_BATCH_H_
+#define SYNC_INTERNAL_API_PUBLIC_FULLY_SERIALIZED_METADATA_BATCH_H_
+
+#include <string>
+
+#include "sync/api/metadata_batch.h"
+
+namespace syncer_v2 {
+
+// An implementation of MetadataBatch meant for services that have no need to
+// understand any of the sync metadata, and simply store/read it in a fully
+// serialized form.
+class FullySerializedMetadataBatch : public MetadataBatch {
+ public:
+ // Incorperates the given metadata at the given storage key into the batch,
+ // handling deserialization. Multiple invocations with the same client key is
+ // currently undefined.
+ void PutMetadata(const std::string& client_key,
+ const std::string& serialized_metadata);
+
+ // Incorperates the given global metadata into the batch, handling
+ // deserialization. Multiple invocations will use the last value.
+ void PutGlobalMetadata(const std::string& serialized_global_metadata);
+};
+
+} // namespace syncer_v2
+
+#endif // SYNC_INTERNAL_API_PUBLIC_FULLY_SERIALIZED_METADATA_BATCH_H_
diff --git a/sync/internal_api/public/shared_model_type_processor.h b/sync/internal_api/public/shared_model_type_processor.h
index 0c47f69..a7d8f0f 100644
--- a/sync/internal_api/public/shared_model_type_processor.h
+++ b/sync/internal_api/public/shared_model_type_processor.h
@@ -69,9 +69,9 @@ class SYNC_EXPORT_PRIVATE SharedModelTypeProcessor
void Put(const std::string& client_key,
const std::string& non_unique_name,
const sync_pb::EntitySpecifics& specifics,
- MetadataChanges* metadata_changes) override;
+ MetadataChangeList* metadata_change_list) override;
void Delete(const std::string& client_key,
- MetadataChanges* metadata_changes) override;
+ MetadataChangeList* metadata_change_list) override;
// Returns the list of pending updates.
//
diff --git a/sync/internal_api/public/simple_metadata_change_list.cc b/sync/internal_api/public/simple_metadata_change_list.cc
new file mode 100644
index 0000000..27d2b41
--- /dev/null
+++ b/sync/internal_api/public/simple_metadata_change_list.cc
@@ -0,0 +1,19 @@
+// Copyright 2015 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/simple_metadata_change_list.h"
+
+namespace syncer_v2 {
+
+SimpleMetadataChangeList::SimpleMetadataChangeList() {}
+
+SimpleMetadataChangeList::~SimpleMetadataChangeList() {}
+
+void SimpleMetadataChangeList::TranfserChanges(
+ ModelTypeStore* store,
+ ModelTypeStore::WriteBatch* write_batch) {
+ // TODO(skym): Implementation.
+}
+
+} // namespace syncer_v2
diff --git a/sync/internal_api/public/simple_metadata_change_list.h b/sync/internal_api/public/simple_metadata_change_list.h
new file mode 100644
index 0000000..12bbe59
--- /dev/null
+++ b/sync/internal_api/public/simple_metadata_change_list.h
@@ -0,0 +1,31 @@
+// Copyright 2015 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_SIMPLE_METADATA_CHANGE_LIST_H_
+#define SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_
+
+#include "sync/api/metadata_change_list.h"
+#include "sync/api/model_type_store.h"
+#include "sync/base/sync_export.h"
+
+namespace syncer_v2 {
+
+// A MetadataChangeList implementation that is meant to be used in combination
+// with a ModelTypeStore. It accumulates changes in member fields, and then when
+// requested transfers them to the store/write batch.
+class SYNC_EXPORT SimpleMetadataChangeList : public MetadataChangeList {
+ public:
+ SimpleMetadataChangeList();
+ ~SimpleMetadataChangeList() override;
+
+ // Moves all currently accumulated changes into the write batch, clear out
+ // local copies. Calling this multiple times will work, but should not be
+ // necessary.
+ void TranfserChanges(ModelTypeStore* store,
+ ModelTypeStore::WriteBatch* write_batch);
+};
+
+} // namespace syncer_v2
+
+#endif // SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_
diff --git a/sync/internal_api/public/specifics_only_data_batch.cc b/sync/internal_api/public/specifics_only_data_batch.cc
new file mode 100644
index 0000000..37896a7
--- /dev/null
+++ b/sync/internal_api/public/specifics_only_data_batch.cc
@@ -0,0 +1,15 @@
+// Copyright 2015 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/specifics_only_data_batch.h"
+
+namespace syncer_v2 {
+
+void SpecificsOnlyDataBatch::Put(
+ const std::string& client_key,
+ scoped_ptr<sync_pb::EntitySpecifics> specifics) {
+ // TODO(skym): Implementation.
+}
+
+} // namespace syncer_v2
diff --git a/sync/internal_api/public/specifics_only_data_batch.h b/sync/internal_api/public/specifics_only_data_batch.h
new file mode 100644
index 0000000..bb3aa19
--- /dev/null
+++ b/sync/internal_api/public/specifics_only_data_batch.h
@@ -0,0 +1,29 @@
+// Copyright 2015 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_SPECIFICS_ONLY_DATA_BATCH_H_
+#define SYNC_INTERNAL_API_PUBLIC_SPECIFICS_ONLY_DATA_BATCH_H_
+
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "sync/api/data_batch.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace syncer_v2 {
+
+// An implementation of DataBatch that only takes the simplest data from the
+// service. The processor may need to help populate some fields.
+class SpecificsOnlyDataBatch : public DataBatch {
+ public:
+ // Takes ownership of the specifics tied to a given key used for storage. Put
+ // should be called at most once for any given client_key. Multiple uses of
+ // the same client_key is currently undefined.
+ void Put(const std::string& client_key,
+ scoped_ptr<sync_pb::EntitySpecifics> specifics);
+};
+
+} // namespace syncer_v2
+
+#endif // SYNC_INTERNAL_API_PUBLIC_SPECIFICS_ONLY_DATA_BATCH_H_
diff --git a/sync/internal_api/shared_model_type_processor.cc b/sync/internal_api/shared_model_type_processor.cc
index 97275a9..e653d62 100644
--- a/sync/internal_api/shared_model_type_processor.cc
+++ b/sync/internal_api/shared_model_type_processor.cc
@@ -147,13 +147,12 @@ void SharedModelTypeProcessor::OnConnect(scoped_ptr<CommitQueue> worker) {
FlushPendingCommitRequests();
}
-void SharedModelTypeProcessor::Put(
- const std::string& client_tag,
- const std::string& non_unique_name,
- const sync_pb::EntitySpecifics& specifics,
- MetadataChanges* metadata_changes) {
+void SharedModelTypeProcessor::Put(const std::string& client_tag,
+ const std::string& non_unique_name,
+ const sync_pb::EntitySpecifics& specifics,
+ MetadataChangeList* metadata_change_list) {
// TODO(skym): Update for new approach. Different objects, different caching,
- // different loopups, metadat_changes, etc.
+ // different loopups, metadata_change_list, etc.
DCHECK_EQ(type_, syncer::GetModelTypeFromSpecifics(specifics));
@@ -173,8 +172,9 @@ void SharedModelTypeProcessor::Put(
FlushPendingCommitRequests();
}
-void SharedModelTypeProcessor::Delete(const std::string& client_key,
- MetadataChanges* metadata_changes) {
+void SharedModelTypeProcessor::Delete(
+ const std::string& client_key,
+ MetadataChangeList* metadata_change_list) {
// TODO(skym): Update for new approach. Different caching, different lookup,
// metadata changes.
diff --git a/sync/sync.gyp b/sync/sync.gyp
index bd41f74..45943fc 100644
--- a/sync/sync.gyp
+++ b/sync/sync.gyp
@@ -82,7 +82,7 @@
'api/entity_data.cc',
'api/entity_data.h',
'api/metadata_batch.h',
- 'api/metadata_changes.h',
+ 'api/metadata_change_list.h',
'api/model_type_change_processor.cc',
'api/model_type_change_processor.h',
'api/model_type_service.cc',
@@ -288,6 +288,8 @@
'internal_api/public/events/normal_get_updates_request_event.h',
'internal_api/public/events/poll_get_updates_request_event.h',
'internal_api/public/events/protocol_event.h',
+ 'internal_api/public/fully_serialized_metadata_batch.h',
+ 'internal_api/public/fully_serialized_metadata_batch.cc',
'internal_api/public/http_bridge.h',
'internal_api/public/http_bridge_network_resources.h',
'internal_api/public/http_post_provider_factory.h',
@@ -317,6 +319,10 @@
'internal_api/public/sessions/update_counters.h',
'internal_api/public/shared_model_type_processor.h',
'internal_api/public/shutdown_reason.h',
+ 'internal_api/public/simple_metadata_change_list.cc',
+ 'internal_api/public/simple_metadata_change_list.h',
+ 'internal_api/public/specifics_only_data_batch.h',
+ 'internal_api/public/specifics_only_data_batch.cc',
'internal_api/public/sync_auth_provider.h',
'internal_api/public/sync_context.h',
'internal_api/public/sync_context_proxy.h',