Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: sync/internal_api/public/base/invalidation.h

Issue 23754021: Invalidation trickles mega-patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 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/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/time/time.h" 12 #include "base/values.h"
13 #include "google/cacheinvalidation/include/types.h"
13 #include "sync/base/sync_export.h" 14 #include "sync/base/sync_export.h"
14 15 #include "sync/internal_api/public/base/ack_handle.h"
15 namespace base { 16 #include "sync/internal_api/public/util/weak_handle.h"
16 class DictionaryValue;
17 } // namespace
18 17
19 namespace syncer { 18 namespace syncer {
20 19
21 // Opaque class that represents a local ack handle. We don't reuse the 20 class DroppedInvalidationTracker;
22 // invalidation ack handles to avoid unnecessary dependencies. 21 class AckHandler;
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 22
45 // Represents a local invalidation, and is roughly analogous to 23 // Represents a local invalidation, and is roughly analogous to
46 // invalidation::Invalidation. It contains a version (which may be 24 // invalidation::Invalidation.
47 // kUnknownVersion), a payload (which may be empty) and an 25 class SYNC_EXPORT Invalidation {
48 // associated ack handle that an InvalidationHandler implementation can use to 26 public:
49 // acknowledge receipt of the invalidation. It does not embed the object ID, 27 // Factory functions.
50 // since it is typically associated with it through ObjectIdInvalidationMap. 28 static Invalidation Init(
51 struct SYNC_EXPORT Invalidation { 29 const invalidation::ObjectId& id,
52 static const int64 kUnknownVersion; 30 int64 version,
31 const std::string& payload);
32 static Invalidation InitUnknownVersion(const invalidation::ObjectId& id);
33 static Invalidation InitFromDroppedInvalidation(const Invalidation& dropped);
53 34
54 Invalidation(); 35 Invalidation();
55 ~Invalidation(); 36 ~Invalidation();
56 37
57 bool Equals(const Invalidation& other) const; 38 // Compares two invalidations. The comparison ignores ack-tracking state.
39 bool operator==(const Invalidation& other) const;
40
41 invalidation::ObjectId GetObjectId() const;
42 bool IsUnknownVersion() const;
43
44 // These functions may be called only if IsUnknownVersion() returns false.
45 int64 GetVersion() const;
46 const std::string& GetPayload() const;
47
48 void Acknowledge() const;
49 void Drop(DroppedInvalidationTracker* tracker) const;
50
51 const AckHandle& GetAckHandle() const;
52
53 void SetAckHandler(syncer::WeakHandle<AckHandler> ack_handler);
54 bool SupportsAcknowledgement() const;
58 55
59 scoped_ptr<base::DictionaryValue> ToValue() const; 56 scoped_ptr<base::DictionaryValue> ToValue() const;
60 bool ResetFromValue(const base::DictionaryValue& value); 57 bool ResetFromValue(const base::DictionaryValue& value);
58 std::string ToString() const;
61 59
62 int64 version; 60 private:
63 std::string payload; 61 Invalidation(const invalidation::ObjectId& id,
64 AckHandle ack_handle; 62 bool is_unknown_version,
63 int64 version,
64 const std::string& payload,
65 AckHandle ack_handle);
66
67 invalidation::ObjectId id_;
68 bool is_unknown_version_;
69 int64 version_;
70 std::string payload_;
71
72 AckHandle ack_handle_;
73 syncer::WeakHandle<AckHandler> ack_handler_;
65 }; 74 };
66 75
67 } // namespace syncer 76 } // namespace syncer
68 77
69 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ 78 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/base/ack_handle.cc ('k') | sync/internal_api/public/base/invalidation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698