| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_INVALIDATION_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 class DictionaryValue; | 14 class DictionaryValue; |
| 14 class Value; | |
| 15 } // namespace | 15 } // namespace |
| 16 | 16 |
| 17 namespace syncer { | 17 namespace syncer { |
| 18 | 18 |
| 19 // Opaque class that represents an ack handle. | 19 // Opaque class that represents a local ack handle. We don't reuse the |
| 20 // TODO(dcheng): This is just a refactoring change, so the class is empty for | 20 // invalidation ack handles to avoid unnecessary dependencies. |
| 21 // the moment. It will be filled once we start implementing 'reminders'. | |
| 22 class AckHandle { | 21 class AckHandle { |
| 23 public: | 22 public: |
| 23 static AckHandle CreateUnique(); |
| 24 static AckHandle InvalidAckHandle(); |
| 25 |
| 24 bool Equals(const AckHandle& other) const; | 26 bool Equals(const AckHandle& other) const; |
| 25 | 27 |
| 26 scoped_ptr<base::Value> ToValue() const; | 28 scoped_ptr<base::DictionaryValue> ToValue() const; |
| 29 bool ResetFromValue(const base::DictionaryValue& value); |
| 27 | 30 |
| 28 bool ResetFromValue(const base::Value& value); | 31 bool IsValid() const; |
| 32 |
| 33 private: |
| 34 // We are explicitly copyable and assignable for STL containers. |
| 35 AckHandle(const std::string& state); |
| 36 |
| 37 std::string state_; |
| 29 }; | 38 }; |
| 30 | 39 |
| 31 // Represents a local invalidation, and is roughly analogous to | 40 // Represents a local invalidation, and is roughly analogous to |
| 32 // invalidation::Invalidation. It contains a payload (which may be empty) and an | 41 // invalidation::Invalidation. It contains a payload (which may be empty) and an |
| 33 // associated ack handle that an InvalidationHandler implementation can use to | 42 // associated ack handle that an InvalidationHandler implementation can use to |
| 34 // acknowledge receipt of the invalidation. It does not embed the object ID, | 43 // acknowledge receipt of the invalidation. It does not embed the object ID, |
| 35 // since it is typically associated with it through ObjectIdInvalidationMap. | 44 // since it is typically associated with it through ObjectIdInvalidationMap. |
| 36 struct Invalidation { | 45 struct Invalidation { |
| 37 std::string payload; | 46 Invalidation(); |
| 38 AckHandle ack_handle; | |
| 39 | 47 |
| 40 bool Equals(const Invalidation& other) const; | 48 bool Equals(const Invalidation& other) const; |
| 41 | 49 |
| 42 // Caller owns the returned DictionaryValue. | |
| 43 scoped_ptr<base::DictionaryValue> ToValue() const; | 50 scoped_ptr<base::DictionaryValue> ToValue() const; |
| 51 bool ResetFromValue(const base::DictionaryValue& value); |
| 44 | 52 |
| 45 bool ResetFromValue(const base::DictionaryValue& value); | 53 std::string payload; |
| 54 AckHandle ack_handle; |
| 46 }; | 55 }; |
| 47 | 56 |
| 48 } // namespace syncer | 57 } // namespace syncer |
| 49 | 58 |
| 50 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ | 59 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ |
| OLD | NEW |