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 GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_ |
6 #define GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "google_apis/gcm/engine/account_mapping.h" | 22 #include "google_apis/gcm/engine/account_mapping.h" |
23 | 23 |
24 namespace gcm { | 24 namespace gcm { |
25 | 25 |
26 class MCSMessage; | 26 class MCSMessage; |
27 | 27 |
28 // A GCM data store interface. GCM Store will handle persistence portion of RMQ, | 28 // A GCM data store interface. GCM Store will handle persistence portion of RMQ, |
29 // as well as store device and user checkin information. | 29 // as well as store device and user checkin information. |
30 class GCM_EXPORT GCMStore { | 30 class GCM_EXPORT GCMStore { |
31 public: | 31 public: |
| 32 enum StoreOpenMode { |
| 33 DO_NOT_CREATE, |
| 34 CREATE_IF_MISSING |
| 35 }; |
| 36 |
32 // Map of message id to message data for outgoing messages. | 37 // Map of message id to message data for outgoing messages. |
33 typedef std::map<std::string, linked_ptr<google::protobuf::MessageLite> > | 38 typedef std::map<std::string, linked_ptr<google::protobuf::MessageLite> > |
34 OutgoingMessageMap; | 39 OutgoingMessageMap; |
35 | 40 |
36 // List of account mappings. | 41 // List of account mappings. |
37 typedef std::vector<AccountMapping> AccountMappings; | 42 typedef std::vector<AccountMapping> AccountMappings; |
38 | 43 |
39 // Container for Load(..) results. | 44 // Container for Load(..) results. |
40 struct GCM_EXPORT LoadResult { | 45 struct GCM_EXPORT LoadResult { |
41 LoadResult(); | 46 LoadResult(); |
42 ~LoadResult(); | 47 ~LoadResult(); |
43 | 48 |
44 void Reset(); | 49 void Reset(); |
45 | 50 |
46 bool success; | 51 bool success; |
| 52 bool store_does_not_exist; |
47 uint64 device_android_id; | 53 uint64 device_android_id; |
48 uint64 device_security_token; | 54 uint64 device_security_token; |
49 std::map<std::string, std::string> registrations; | 55 std::map<std::string, std::string> registrations; |
50 std::vector<std::string> incoming_messages; | 56 std::vector<std::string> incoming_messages; |
51 OutgoingMessageMap outgoing_messages; | 57 OutgoingMessageMap outgoing_messages; |
52 std::map<std::string, std::string> gservices_settings; | 58 std::map<std::string, std::string> gservices_settings; |
53 std::string gservices_digest; | 59 std::string gservices_digest; |
54 base::Time last_checkin_time; | 60 base::Time last_checkin_time; |
55 std::set<std::string> last_checkin_accounts; | 61 std::set<std::string> last_checkin_accounts; |
56 AccountMappings account_mappings; | 62 AccountMappings account_mappings; |
57 base::Time last_token_fetch_time; | 63 base::Time last_token_fetch_time; |
58 std::map<std::string, int> heartbeat_intervals; | 64 std::map<std::string, int> heartbeat_intervals; |
59 std::map<std::string, std::string> instance_id_data; | 65 std::map<std::string, std::string> instance_id_data; |
60 }; | 66 }; |
61 | 67 |
62 typedef std::vector<std::string> PersistentIdList; | 68 typedef std::vector<std::string> PersistentIdList; |
63 typedef base::Callback<void(scoped_ptr<LoadResult> result)> LoadCallback; | 69 typedef base::Callback<void(scoped_ptr<LoadResult> result)> LoadCallback; |
64 typedef base::Callback<void(bool success)> UpdateCallback; | 70 typedef base::Callback<void(bool success)> UpdateCallback; |
65 | 71 |
66 GCMStore(); | 72 GCMStore(); |
67 virtual ~GCMStore(); | 73 virtual ~GCMStore(); |
68 | 74 |
69 // Load the data from persistent store and pass the initial state back to | 75 // Load the data from persistent store and pass the initial state back to |
70 // caller. | 76 // caller. |
71 virtual void Load(const LoadCallback& callback) = 0; | 77 virtual void Load(StoreOpenMode open_mode, const LoadCallback& callback) = 0; |
72 | 78 |
73 // Close the persistent store. | 79 // Close the persistent store. |
74 virtual void Close() = 0; | 80 virtual void Close() = 0; |
75 | 81 |
76 // Clears the GCM store of all data. | 82 // Clears the GCM store of all data. |
77 virtual void Destroy(const UpdateCallback& callback) = 0; | 83 virtual void Destroy(const UpdateCallback& callback) = 0; |
78 | 84 |
79 // Sets this device's messaging credentials. | 85 // Sets this device's messaging credentials. |
80 virtual void SetDeviceCredentials(uint64 device_android_id, | 86 virtual void SetDeviceCredentials(uint64 device_android_id, |
81 uint64 device_security_token, | 87 uint64 device_security_token, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 virtual void RemoveInstanceIDData(const std::string& app_id, | 158 virtual void RemoveInstanceIDData(const std::string& app_id, |
153 const UpdateCallback& callback) = 0; | 159 const UpdateCallback& callback) = 0; |
154 | 160 |
155 private: | 161 private: |
156 DISALLOW_COPY_AND_ASSIGN(GCMStore); | 162 DISALLOW_COPY_AND_ASSIGN(GCMStore); |
157 }; | 163 }; |
158 | 164 |
159 } // namespace gcm | 165 } // namespace gcm |
160 | 166 |
161 #endif // GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_ | 167 #endif // GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_ |
OLD | NEW |