summaryrefslogtreecommitdiffstats
path: root/sync/api
diff options
context:
space:
mode:
authormaxbogue <maxbogue@chromium.org>2015-11-20 11:42:43 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-20 19:43:45 +0000
commitbccc5c48c5345726cf02863e19f80151af95bfc4 (patch)
tree4d758b1cf8f5620f240c1e2449f335f260bdf0a1 /sync/api
parent38152e7ee5c9daace6e192d9478ad01740defaee (diff)
downloadchromium_src-bccc5c48c5345726cf02863e19f80151af95bfc4.zip
chromium_src-bccc5c48c5345726cf02863e19f80151af95bfc4.tar.gz
chromium_src-bccc5c48c5345726cf02863e19f80151af95bfc4.tar.bz2
[Sync] Adding USS interfaces for processor-service communication.
Copying Sky's patch since he's out. BUG=536895,543405 patch from issue 1444083002 at patchset 20001 (http://crrev.com/1444083002#ps20001) Review URL: https://codereview.chromium.org/1462233002 Cr-Commit-Position: refs/heads/master@{#360885}
Diffstat (limited to 'sync/api')
-rw-r--r--sync/api/data_batch.h21
-rw-r--r--sync/api/entity_data.h1
-rw-r--r--sync/api/metadata_batch.h21
-rw-r--r--sync/api/metadata_changes.h21
-rw-r--r--sync/api/model_type_change_processor.h20
-rw-r--r--sync/api/model_type_service.cc14
-rw-r--r--sync/api/model_type_service.h61
7 files changed, 159 insertions, 0 deletions
diff --git a/sync/api/data_batch.h b/sync/api/data_batch.h
new file mode 100644
index 0000000..63359cf
--- /dev/null
+++ b/sync/api/data_batch.h
@@ -0,0 +1,21 @@
+// 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_API_DATA_BATCH_H_
+#define SYNC_API_DATA_BATCH_H_
+
+#include "sync/base/sync_export.h"
+
+namespace syncer_v2 {
+
+// Interface used by the processor and service to communicate about data.
+class SYNC_EXPORT DataBatch {
+ public:
+ DataBatch() {}
+ virtual ~DataBatch() {}
+};
+
+} // namespace syncer_v2
+
+#endif // SYNC_API_DATA_BATCH_H_
diff --git a/sync/api/entity_data.h b/sync/api/entity_data.h
index 66a6a99..4fe88510 100644
--- a/sync/api/entity_data.h
+++ b/sync/api/entity_data.h
@@ -25,6 +25,7 @@ struct SYNC_EXPORT EntityDataTraits {
};
typedef syncer::ProtoValuePtr<EntityData, EntityDataTraits> EntityDataPtr;
+typedef std::vector<EntityDataPtr> EntityDataList;
// A light-weight container for sync entity data which represents either
// local data created on the ModelTypeService side or remote data created
diff --git a/sync/api/metadata_batch.h b/sync/api/metadata_batch.h
new file mode 100644
index 0000000..56ffffb
--- /dev/null
+++ b/sync/api/metadata_batch.h
@@ -0,0 +1,21 @@
+// 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_API_METADATA_BATCH_H_
+#define SYNC_API_METADATA_BATCH_H_
+
+#include "sync/base/sync_export.h"
+
+namespace syncer_v2 {
+
+// Interface used by the processor and service to communicate about metadata.
+class SYNC_EXPORT MetadataBatch {
+ public:
+ MetadataBatch() {}
+ virtual ~MetadataBatch() {}
+};
+
+} // namespace syncer_v2
+
+#endif // SYNC_API_METADATA_BATCH_H_
diff --git a/sync/api/metadata_changes.h b/sync/api/metadata_changes.h
new file mode 100644
index 0000000..a3d4d3b
--- /dev/null
+++ b/sync/api/metadata_changes.h
@@ -0,0 +1,21 @@
+// 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_API_METADATA_CHANGES_H_
+#define SYNC_API_METADATA_CHANGES_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 {
+ public:
+ MetadataChanges() {}
+ virtual ~MetadataChanges() {}
+};
+
+} // namespace syncer_v2
+
+#endif // SYNC_API_METADATA_CHANGES_H_
diff --git a/sync/api/model_type_change_processor.h b/sync/api/model_type_change_processor.h
index 85f8d16..7781a0e 100644
--- a/sync/api/model_type_change_processor.h
+++ b/sync/api/model_type_change_processor.h
@@ -5,16 +5,36 @@
#ifndef SYNC_API_MODEL_TYPE_CHANGE_PROCESSOR_H_
#define SYNC_API_MODEL_TYPE_CHANGE_PROCESSOR_H_
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "sync/api/entity_data.h"
#include "sync/base/sync_export.h"
+namespace syncer {
+class SyncError;
+} // namespace syncer
+
namespace syncer_v2 {
+class MetadataChanges;
+
// Interface used by the ModelTypeService to inform sync of local
// changes.
class SYNC_EXPORT ModelTypeChangeProcessor {
public:
ModelTypeChangeProcessor();
virtual ~ModelTypeChangeProcessor();
+
+ // Inform the processor of a new or updated entity.
+ virtual void Put(const std::string& client_key,
+ const std::string& non_unique_name,
+ const sync_pb::EntitySpecifics& specifics,
+ MetadataChanges* metadata_changes) = 0;
+
+ // Inform the processor of a deleted entity.
+ virtual void Delete(const std::string& client_key,
+ MetadataChanges* metadata_changes) = 0;
};
} // namespace syncer_v2
diff --git a/sync/api/model_type_service.cc b/sync/api/model_type_service.cc
index 61ea860..759860a 100644
--- a/sync/api/model_type_service.cc
+++ b/sync/api/model_type_service.cc
@@ -10,4 +10,18 @@ ModelTypeService::ModelTypeService() {}
ModelTypeService::~ModelTypeService() {}
+syncer_v2::ModelTypeChangeProcessor* ModelTypeService::change_processor() {
+ return change_processor_.get();
+}
+
+void ModelTypeService::set_change_processor(
+ scoped_ptr<syncer_v2::ModelTypeChangeProcessor> change_processor) {
+ DCHECK(!change_processor_);
+ change_processor_.swap(change_processor);
+}
+
+void ModelTypeService::clear_change_processor() {
+ change_processor_.reset();
+}
+
} // namespace syncer_v2
diff --git a/sync/api/model_type_service.h b/sync/api/model_type_service.h
index d01dc87..473c9c1 100644
--- a/sync/api/model_type_service.h
+++ b/sync/api/model_type_service.h
@@ -5,17 +5,78 @@
#ifndef SYNC_API_MODEL_TYPE_SERVICE_H_
#define SYNC_API_MODEL_TYPE_SERVICE_H_
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "sync/api/entity_data.h"
+#include "sync/api/model_type_change_processor.h"
#include "sync/base/sync_export.h"
+namespace syncer {
+class SyncError;
+} // namespace syncer
+
namespace syncer_v2 {
+class DataBatch;
+class MetadataBatch;
+class MetadataChanges;
+
// Interface implemented by model types to receive updates from sync via the
// SharedModelTypeProcessor. Provides a way for sync to update the data and
// metadata for entities, as well as the model type state.
class SYNC_EXPORT ModelTypeService {
public:
+ typedef base::Callback<void(syncer::SyncError, scoped_ptr<DataBatch>)>
+ DataCallback;
+ typedef base::Callback<void(syncer::SyncError, scoped_ptr<MetadataBatch>)>
+ MetadataCallback;
+ typedef std::vector<std::string> ClientKeyList;
+
ModelTypeService();
+
virtual ~ModelTypeService();
+
+ // Creates an object used to communicate changes in the sync metadata to the
+ // model type store.
+ virtual MetadataChanges* CreateMetadataChanges() = 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;
+
+ // Apply changes from the sync server locally.
+ // TODO(skym): The change type should be in here somehow.
+ virtual syncer::SyncError ApplySyncChanges(
+ MetadataChanges* metadata_changes,
+ EntityDataList entity_data_list) = 0;
+
+ // Asynchronously retrieve the sync metadata.
+ virtual void LoadMetadata(MetadataCallback callback) = 0;
+
+ // Asynchronously retrieve the corresponding sync data for |client_keys|.
+ virtual void GetData(ClientKeyList client_keys, DataCallback callback) = 0;
+
+ // Asynchronously retrieve all of the local sync data.
+ virtual void GetAllData(DataCallback callback) = 0;
+
+ // Get or generate a client tag for |entity_data|.
+ virtual std::string GetClientTag(const EntityData* entity_data) = 0;
+
+ // TODO(skym): See crbug/547087, do we need all these accessors?
+ syncer_v2::ModelTypeChangeProcessor* change_processor();
+
+ void set_change_processor(
+ scoped_ptr<syncer_v2::ModelTypeChangeProcessor> change_processor);
+
+ void clear_change_processor();
+
+ private:
+ // Recieves ownership in set_change_processor(...).
+ scoped_ptr<syncer_v2::ModelTypeChangeProcessor> change_processor_;
};
} // namespace syncer_v2