| 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_BASE_INVALIDATION_INTERFACE_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_INTERFACE_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_INTERFACE_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_INTERFACE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | |
| 11 #include "sync/base/sync_export.h" | 12 #include "sync/base/sync_export.h" |
| 12 | 13 |
| 13 namespace syncer { | 14 namespace syncer { |
| 14 | 15 |
| 15 // An interface that wraps sync's interactions with the component that provides | 16 // An interface that wraps sync's interactions with the component that provides |
| 16 // it with invalidations. | 17 // it with invalidations. |
| 17 class SYNC_EXPORT InvalidationInterface { | 18 class SYNC_EXPORT InvalidationInterface { |
| 18 public: | 19 public: |
| 19 // Orders invalidations based on version number and IsUnknownVersion(). | 20 // Orders invalidations based on version number and IsUnknownVersion(). |
| 20 static bool LessThanByVersion(const InvalidationInterface& a, | 21 static bool LessThanByVersion(const InvalidationInterface& a, |
| 21 const InvalidationInterface& b); | 22 const InvalidationInterface& b); |
| 22 | 23 |
| 23 InvalidationInterface(); | 24 InvalidationInterface(); |
| 24 virtual ~InvalidationInterface(); | 25 virtual ~InvalidationInterface(); |
| 25 | 26 |
| 26 // Returns true if this is an 'unknown version' invalidation. | 27 // Returns true if this is an 'unknown version' invalidation. |
| 27 // Such invalidations have no valid payload or version number. | 28 // Such invalidations have no valid payload or version number. |
| 28 virtual bool IsUnknownVersion() const = 0; | 29 virtual bool IsUnknownVersion() const = 0; |
| 29 | 30 |
| 30 // Returns the payload of this item. | 31 // Returns the payload of this item. |
| 31 // DCHECKs if this is an unknown version invalidation. | 32 // DCHECKs if this is an unknown version invalidation. |
| 32 virtual const std::string& GetPayload() const = 0; | 33 virtual const std::string& GetPayload() const = 0; |
| 33 | 34 |
| 34 // Retursn the version of this item. | 35 // Retursn the version of this item. |
| 35 // DCHECKs if this is an unknown version invalidation. | 36 // DCHECKs if this is an unknown version invalidation. |
| 36 // | 37 // |
| 37 // It is preferable to use the LessThan() function, which handles unknown | 38 // It is preferable to use the LessThan() function, which handles unknown |
| 38 // versions properly, rather than this function. | 39 // versions properly, rather than this function. |
| 39 virtual int64 GetVersion() const = 0; | 40 virtual int64_t GetVersion() const = 0; |
| 40 | 41 |
| 41 // This function will be called when the invalidation has been handled | 42 // This function will be called when the invalidation has been handled |
| 42 // successfully. | 43 // successfully. |
| 43 virtual void Acknowledge() = 0; | 44 virtual void Acknowledge() = 0; |
| 44 | 45 |
| 45 // This function should be called if a lack of buffer space required that we | 46 // This function should be called if a lack of buffer space required that we |
| 46 // drop this invalidation. | 47 // drop this invalidation. |
| 47 // | 48 // |
| 48 // To indicate recovery from a drop event, the receiver of this invalidation | 49 // To indicate recovery from a drop event, the receiver of this invalidation |
| 49 // will call Acknowledge() on the most recently dropped invalidation. | 50 // will call Acknowledge() on the most recently dropped invalidation. |
| 50 virtual void Drop() = 0; | 51 virtual void Drop() = 0; |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 } // namespace syncer | 54 } // namespace syncer |
| 54 | 55 |
| 55 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_INTERFACE_H_ | 56 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_INTERFACE_H_ |
| OLD | NEW |