Home | History | Annotate | Download | only in base
      1 // Copyright 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_
      6 #define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/memory/scoped_ptr.h"
     12 #include "base/time/time.h"
     13 #include "sync/base/sync_export.h"
     14 
     15 namespace base {
     16 class DictionaryValue;
     17 }  // namespace
     18 
     19 namespace syncer {
     20 
     21 // Opaque class that represents a local ack handle. We don't reuse the
     22 // invalidation ack handles to avoid unnecessary dependencies.
     23 class SYNC_EXPORT AckHandle {
     24  public:
     25   static AckHandle CreateUnique();
     26   static AckHandle InvalidAckHandle();
     27 
     28   bool Equals(const AckHandle& other) const;
     29 
     30   scoped_ptr<base::DictionaryValue> ToValue() const;
     31   bool ResetFromValue(const base::DictionaryValue& value);
     32 
     33   bool IsValid() const;
     34 
     35   ~AckHandle();
     36 
     37  private:
     38   // Explicitly copyable and assignable for STL containers.
     39   AckHandle(const std::string& state, base::Time timestamp);
     40 
     41   std::string state_;
     42   base::Time timestamp_;
     43 };
     44 
     45 // Represents a local invalidation, and is roughly analogous to
     46 // invalidation::Invalidation. It contains a version (which may be
     47 // kUnknownVersion), a payload (which may be empty) and an
     48 // associated ack handle that an InvalidationHandler implementation can use to
     49 // acknowledge receipt of the invalidation. It does not embed the object ID,
     50 // since it is typically associated with it through ObjectIdInvalidationMap.
     51 struct SYNC_EXPORT Invalidation {
     52   static const int64 kUnknownVersion;
     53 
     54   Invalidation();
     55   ~Invalidation();
     56 
     57   bool Equals(const Invalidation& other) const;
     58 
     59   scoped_ptr<base::DictionaryValue> ToValue() const;
     60   bool ResetFromValue(const base::DictionaryValue& value);
     61 
     62   int64 version;
     63   std::string payload;
     64   AckHandle ack_handle;
     65 };
     66 
     67 }  // namespace syncer
     68 
     69 #endif  // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_
     70