OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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 GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_ | |
6 #define GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/callback_forward.h" | |
14 #include "base/memory/ref_counted.h" | |
15 #include "google_apis/gcm/base/gcm_export.h" | |
16 | |
17 namespace google { | |
18 namespace protobuf { | |
19 class MessageLite; | |
20 } // namespace protobuf | |
21 } // namespace google | |
22 | |
23 namespace gcm { | |
24 | |
25 class MCSMessage; | |
26 | |
27 // A GCM data store interface. GCM Store will handle persistence portion of RMQ, | |
28 // as well as store device and user checkin information. | |
29 class GCM_EXPORT GCMStore { | |
30 public: | |
31 // Container for Load(..) results. | |
32 struct GCM_EXPORT LoadResult { | |
33 LoadResult(); | |
34 ~LoadResult(); | |
35 | |
36 bool success; | |
37 uint64 device_android_id; | |
38 uint64 device_security_token; | |
39 std::vector<std::string> incoming_messages; | |
40 std::map<std::string, google::protobuf::MessageLite*> outgoing_messages; | |
41 int64 next_serial_number; | |
42 std::map<std::string, int64> user_serial_numbers; | |
43 }; | |
44 | |
45 typedef std::vector<std::string> PersistentIdList; | |
46 // Note: callee receives ownership of |outgoing_messages|' values. | |
47 typedef base::Callback<void(const LoadResult& result)> LoadCallback; | |
48 typedef base::Callback<void(bool success)> UpdateCallback; | |
49 | |
50 GCMStore(); | |
51 virtual ~GCMStore() = 0; | |
jianli
2014/01/02 19:02:53
Why making it abstract? You implemented it in .cc
fgorski
2014/01/02 19:46:33
Done.
| |
52 | |
53 // Load the data from persistent store and pass the initial state back to | |
54 // caller. | |
55 virtual void Load(const LoadCallback& callback) = 0; | |
56 | |
57 // Clears the GCM store of all data. | |
58 virtual void Destroy(const UpdateCallback& callback) = 0; | |
59 | |
60 // Sets this device's messaging credentials. | |
61 virtual void SetDeviceCredentials(uint64 device_android_id, | |
62 uint64 device_security_token, | |
63 const UpdateCallback& callback) = 0; | |
64 | |
65 // Unacknowledged incoming message handling. | |
66 virtual void AddIncomingMessage(const std::string& persistent_id, | |
67 const UpdateCallback& callback) = 0; | |
68 virtual void RemoveIncomingMessage(const std::string& persistent_id, | |
69 const UpdateCallback& callback) = 0; | |
70 virtual void RemoveIncomingMessages(const PersistentIdList& persistent_ids, | |
71 const UpdateCallback& callback) = 0; | |
72 | |
73 // Unacknowledged outgoing messages handling. | |
74 virtual void AddOutgoingMessage(const std::string& persistent_id, | |
75 const MCSMessage& message, | |
76 const UpdateCallback& callback) = 0; | |
77 virtual void RemoveOutgoingMessage(const std::string& persistent_id, | |
78 const UpdateCallback& callback) = 0; | |
79 virtual void RemoveOutgoingMessages(const PersistentIdList& persistent_ids, | |
80 const UpdateCallback& callback) = 0; | |
81 | |
82 // User serial number handling. | |
83 virtual void SetNextSerialNumber(int64 next_serial_number, | |
84 const UpdateCallback& callback) = 0; | |
85 virtual void AddUserSerialNumber(const std::string& username, | |
86 int64 serial_number, | |
87 const UpdateCallback& callback) = 0; | |
88 virtual void RemoveUserSerialNumber(const std::string& username, | |
89 const UpdateCallback& callback) = 0; | |
90 | |
91 private: | |
92 DISALLOW_COPY_AND_ASSIGN(GCMStore); | |
93 }; | |
94 | |
95 } // namespace gcm | |
96 | |
97 #endif // GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_ | |
OLD | NEW |