| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "sync/api/entity_data.h" | 14 #include "sync/api/entity_data.h" |
| 15 #include "sync/base/sync_export.h" | 15 #include "sync/base/sync_export.h" |
| 16 #include "sync/protocol/entity_metadata.pb.h" | 16 #include "sync/protocol/entity_metadata.pb.h" |
| 17 | 17 |
| 18 namespace syncer_v2 { | 18 namespace syncer_v2 { |
| 19 struct CommitRequestData; | 19 struct CommitRequestData; |
| 20 struct UpdateResponseData; | 20 struct UpdateResponseData; |
| 21 | 21 |
| 22 // This class is used by the SharedModelTypeProcessor to track the state of each | 22 // This class is used by the SharedModelTypeProcessor to track the state of each |
| 23 // entity with its type. It can be considered a helper class internal to the | 23 // entity with its type. It can be considered a helper class internal to the |
| 24 // processor. It manages the metadata for its entity and caches entity data | 24 // processor. It manages the metadata for its entity and caches entity data |
| 25 // upon a local change until commit confirmation is received. | 25 // upon a local change until commit confirmation is received. |
| 26 class SYNC_EXPORT ProcessorEntityTracker { | 26 class SYNC_EXPORT ProcessorEntityTracker { |
| 27 public: | 27 public: |
| 28 // Construct an instance representing a new locally-created item. | 28 // Construct an instance representing a new locally-created item. |
| 29 static scoped_ptr<ProcessorEntityTracker> CreateNew( | 29 static std::unique_ptr<ProcessorEntityTracker> CreateNew( |
| 30 const std::string& client_tag, | 30 const std::string& client_tag, |
| 31 const std::string& client_tag_hash, | 31 const std::string& client_tag_hash, |
| 32 const std::string& id, | 32 const std::string& id, |
| 33 base::Time creation_time); | 33 base::Time creation_time); |
| 34 | 34 |
| 35 // Construct an instance representing an item loaded from storage on init. | 35 // Construct an instance representing an item loaded from storage on init. |
| 36 // This method swaps out the contents of |metadata|. | 36 // This method swaps out the contents of |metadata|. |
| 37 static scoped_ptr<ProcessorEntityTracker> CreateFromMetadata( | 37 static std::unique_ptr<ProcessorEntityTracker> CreateFromMetadata( |
| 38 const std::string& client_tag, | 38 const std::string& client_tag, |
| 39 sync_pb::EntityMetadata* metadata); | 39 sync_pb::EntityMetadata* metadata); |
| 40 | 40 |
| 41 ~ProcessorEntityTracker(); | 41 ~ProcessorEntityTracker(); |
| 42 | 42 |
| 43 const std::string& client_tag() const { return client_tag_; } | 43 const std::string& client_tag() const { return client_tag_; } |
| 44 const sync_pb::EntityMetadata& metadata() const { return metadata_; } | 44 const sync_pb::EntityMetadata& metadata() const { return metadata_; } |
| 45 const EntityDataPtr& commit_data() const { return commit_data_; } | 45 const EntityDataPtr& commit_data() const { return commit_data_; } |
| 46 | 46 |
| 47 // Returns true if this data is out of sync with the server. | 47 // Returns true if this data is out of sync with the server. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 71 void RecordIgnoredUpdate(const UpdateResponseData& response_data); | 71 void RecordIgnoredUpdate(const UpdateResponseData& response_data); |
| 72 | 72 |
| 73 // Records an update from the server assuming its data is the new data for | 73 // Records an update from the server assuming its data is the new data for |
| 74 // this entity. | 74 // this entity. |
| 75 void RecordAcceptedUpdate(const UpdateResponseData& response_data); | 75 void RecordAcceptedUpdate(const UpdateResponseData& response_data); |
| 76 | 76 |
| 77 // Squashes a pending commit with an update from the server. | 77 // Squashes a pending commit with an update from the server. |
| 78 void RecordForcedUpdate(const UpdateResponseData& response_data); | 78 void RecordForcedUpdate(const UpdateResponseData& response_data); |
| 79 | 79 |
| 80 // Applies a local change to this item. | 80 // Applies a local change to this item. |
| 81 void MakeLocalChange(scoped_ptr<EntityData> data); | 81 void MakeLocalChange(std::unique_ptr<EntityData> data); |
| 82 | 82 |
| 83 // Schedule a commit if the |name| does not match this item's last known | 83 // Schedule a commit if the |name| does not match this item's last known |
| 84 // encryption key. The worker that performs the commit is expected to | 84 // encryption key. The worker that performs the commit is expected to |
| 85 // encrypt the item using the latest available key. | 85 // encrypt the item using the latest available key. |
| 86 void UpdateDesiredEncryptionKey(const std::string& name); | 86 void UpdateDesiredEncryptionKey(const std::string& name); |
| 87 | 87 |
| 88 // Applies a local deletion to this item. | 88 // Applies a local deletion to this item. |
| 89 void Delete(); | 89 void Delete(); |
| 90 | 90 |
| 91 // Initializes a message representing this item's uncommitted state | 91 // Initializes a message representing this item's uncommitted state |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 // TODO(stanisc): this should be removed. | 156 // TODO(stanisc): this should be removed. |
| 157 // The name of the encryption key used to encrypt this item on the server. | 157 // The name of the encryption key used to encrypt this item on the server. |
| 158 // Empty when no encryption is in use. | 158 // Empty when no encryption is in use. |
| 159 std::string encryption_key_name_; | 159 std::string encryption_key_name_; |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 } // namespace syncer_v2 | 162 } // namespace syncer_v2 |
| 163 | 163 |
| 164 #endif // SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_ | 164 #endif // SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_ |
| OLD | NEW |