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

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

Issue 11415049: Implement features needed for local ack handling in InvalidationStateTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ...... Created 8 years 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 (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"
12 #include "base/time.h"
11 13
12 namespace base { 14 namespace base {
13 class DictionaryValue; 15 class DictionaryValue;
14 class Value;
15 } // namespace 16 } // namespace
16 17
17 namespace syncer { 18 namespace syncer {
18 19
19 // Opaque class that represents an ack handle. 20 // 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 21 // invalidation ack handles to avoid unnecessary dependencies.
21 // the moment. It will be filled once we start implementing 'reminders'.
22 class AckHandle { 22 class AckHandle {
23 public: 23 public:
24 static AckHandle CreateUnique();
25 static AckHandle InvalidAckHandle();
26
24 bool Equals(const AckHandle& other) const; 27 bool Equals(const AckHandle& other) const;
25 28
26 scoped_ptr<base::Value> ToValue() const; 29 scoped_ptr<base::DictionaryValue> ToValue() const;
30 bool ResetFromValue(const base::DictionaryValue& value);
27 31
28 bool ResetFromValue(const base::Value& value); 32 bool IsValid() const;
33
34 private:
35 // Explicitly copyable and assignable for STL containers.
36 AckHandle(const std::string& state, base::Time timestamp);
37
38 std::string state_;
39 base::Time timestamp_;
29 }; 40 };
30 41
31 // Represents a local invalidation, and is roughly analogous to 42 // Represents a local invalidation, and is roughly analogous to
32 // invalidation::Invalidation. It contains a payload (which may be empty) and an 43 // invalidation::Invalidation. It contains a payload (which may be empty) and an
33 // associated ack handle that an InvalidationHandler implementation can use to 44 // associated ack handle that an InvalidationHandler implementation can use to
34 // acknowledge receipt of the invalidation. It does not embed the object ID, 45 // acknowledge receipt of the invalidation. It does not embed the object ID,
35 // since it is typically associated with it through ObjectIdInvalidationMap. 46 // since it is typically associated with it through ObjectIdInvalidationMap.
36 struct Invalidation { 47 struct Invalidation {
37 std::string payload; 48 Invalidation();
38 AckHandle ack_handle;
39 49
40 bool Equals(const Invalidation& other) const; 50 bool Equals(const Invalidation& other) const;
41 51
42 // Caller owns the returned DictionaryValue.
43 scoped_ptr<base::DictionaryValue> ToValue() const; 52 scoped_ptr<base::DictionaryValue> ToValue() const;
53 bool ResetFromValue(const base::DictionaryValue& value);
44 54
45 bool ResetFromValue(const base::DictionaryValue& value); 55 std::string payload;
56 AckHandle ack_handle;
46 }; 57 };
47 58
48 } // namespace syncer 59 } // namespace syncer
49 60
50 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_ 61 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/invalidations/invalidator_storage_unittest.cc ('k') | sync/internal_api/public/base/invalidation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698