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_IMPL_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_GCM_STORE_IMPL_H_ |
6 #define GOOGLE_APIS_GCM_ENGINE_GCM_STORE_IMPL_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_GCM_STORE_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // It performs all blocking operations on the blocking task runner, and posts | 24 // It performs all blocking operations on the blocking task runner, and posts |
25 // all callbacks to the thread on which the GCMStoreImpl is created. | 25 // all callbacks to the thread on which the GCMStoreImpl is created. |
26 class GCM_EXPORT GCMStoreImpl : public GCMStore { | 26 class GCM_EXPORT GCMStoreImpl : public GCMStore { |
27 public: | 27 public: |
28 GCMStoreImpl(const base::FilePath& path, | 28 GCMStoreImpl(const base::FilePath& path, |
29 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 29 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
30 scoped_ptr<Encryptor> encryptor); | 30 scoped_ptr<Encryptor> encryptor); |
31 virtual ~GCMStoreImpl(); | 31 virtual ~GCMStoreImpl(); |
32 | 32 |
33 // Load the directory and pass the initial state back to caller. | 33 // Load the directory and pass the initial state back to caller. |
34 virtual void Load(const LoadCallback& callback) OVERRIDE; | 34 virtual void Load(const LoadCallback& callback) override; |
35 | 35 |
36 // Closes the GCM store. | 36 // Closes the GCM store. |
37 virtual void Close() OVERRIDE; | 37 virtual void Close() override; |
38 | 38 |
39 // Clears the GCM store of all data and destroys any LevelDB files associated | 39 // Clears the GCM store of all data and destroys any LevelDB files associated |
40 // with this store. | 40 // with this store. |
41 // WARNING: this will permanently destroy any pending outgoing messages | 41 // WARNING: this will permanently destroy any pending outgoing messages |
42 // and require the device to re-create credentials and serial number mapping | 42 // and require the device to re-create credentials and serial number mapping |
43 // tables. | 43 // tables. |
44 virtual void Destroy(const UpdateCallback& callback) OVERRIDE; | 44 virtual void Destroy(const UpdateCallback& callback) override; |
45 | 45 |
46 // Sets this device's messaging credentials. | 46 // Sets this device's messaging credentials. |
47 virtual void SetDeviceCredentials(uint64 device_android_id, | 47 virtual void SetDeviceCredentials(uint64 device_android_id, |
48 uint64 device_security_token, | 48 uint64 device_security_token, |
49 const UpdateCallback& callback) OVERRIDE; | 49 const UpdateCallback& callback) override; |
50 | 50 |
51 // Registration info. | 51 // Registration info. |
52 virtual void AddRegistration(const std::string& app_id, | 52 virtual void AddRegistration(const std::string& app_id, |
53 const linked_ptr<RegistrationInfo>& registration, | 53 const linked_ptr<RegistrationInfo>& registration, |
54 const UpdateCallback& callback) OVERRIDE; | 54 const UpdateCallback& callback) override; |
55 virtual void RemoveRegistration(const std::string& app_id, | 55 virtual void RemoveRegistration(const std::string& app_id, |
56 const UpdateCallback& callback) OVERRIDE; | 56 const UpdateCallback& callback) override; |
57 | 57 |
58 // Unacknowledged incoming message handling. | 58 // Unacknowledged incoming message handling. |
59 virtual void AddIncomingMessage(const std::string& persistent_id, | 59 virtual void AddIncomingMessage(const std::string& persistent_id, |
60 const UpdateCallback& callback) OVERRIDE; | 60 const UpdateCallback& callback) override; |
61 virtual void RemoveIncomingMessage(const std::string& persistent_id, | 61 virtual void RemoveIncomingMessage(const std::string& persistent_id, |
62 const UpdateCallback& callback) OVERRIDE; | 62 const UpdateCallback& callback) override; |
63 virtual void RemoveIncomingMessages(const PersistentIdList& persistent_ids, | 63 virtual void RemoveIncomingMessages(const PersistentIdList& persistent_ids, |
64 const UpdateCallback& callback) OVERRIDE; | 64 const UpdateCallback& callback) override; |
65 | 65 |
66 // Unacknowledged outgoing messages handling. | 66 // Unacknowledged outgoing messages handling. |
67 virtual bool AddOutgoingMessage(const std::string& persistent_id, | 67 virtual bool AddOutgoingMessage(const std::string& persistent_id, |
68 const MCSMessage& message, | 68 const MCSMessage& message, |
69 const UpdateCallback& callback) OVERRIDE; | 69 const UpdateCallback& callback) override; |
70 virtual void OverwriteOutgoingMessage(const std::string& persistent_id, | 70 virtual void OverwriteOutgoingMessage(const std::string& persistent_id, |
71 const MCSMessage& message, | 71 const MCSMessage& message, |
72 const UpdateCallback& callback) | 72 const UpdateCallback& callback) |
73 OVERRIDE; | 73 override; |
74 virtual void RemoveOutgoingMessage(const std::string& persistent_id, | 74 virtual void RemoveOutgoingMessage(const std::string& persistent_id, |
75 const UpdateCallback& callback) OVERRIDE; | 75 const UpdateCallback& callback) override; |
76 virtual void RemoveOutgoingMessages(const PersistentIdList& persistent_ids, | 76 virtual void RemoveOutgoingMessages(const PersistentIdList& persistent_ids, |
77 const UpdateCallback& callback) OVERRIDE; | 77 const UpdateCallback& callback) override; |
78 | 78 |
79 // Sets last device's checkin information. | 79 // Sets last device's checkin information. |
80 virtual void SetLastCheckinInfo(const base::Time& time, | 80 virtual void SetLastCheckinInfo(const base::Time& time, |
81 const std::set<std::string>& accounts, | 81 const std::set<std::string>& accounts, |
82 const UpdateCallback& callback) OVERRIDE; | 82 const UpdateCallback& callback) override; |
83 | 83 |
84 // G-service settings handling. | 84 // G-service settings handling. |
85 virtual void SetGServicesSettings( | 85 virtual void SetGServicesSettings( |
86 const std::map<std::string, std::string>& settings, | 86 const std::map<std::string, std::string>& settings, |
87 const std::string& settings_digest, | 87 const std::string& settings_digest, |
88 const UpdateCallback& callback) OVERRIDE; | 88 const UpdateCallback& callback) override; |
89 | 89 |
90 // Sets the account information related to device to account mapping. | 90 // Sets the account information related to device to account mapping. |
91 virtual void AddAccountMapping(const AccountMapping& account_mapping, | 91 virtual void AddAccountMapping(const AccountMapping& account_mapping, |
92 const UpdateCallback& callback) OVERRIDE; | 92 const UpdateCallback& callback) override; |
93 virtual void RemoveAccountMapping(const std::string& account_id, | 93 virtual void RemoveAccountMapping(const std::string& account_id, |
94 const UpdateCallback& callback) OVERRIDE; | 94 const UpdateCallback& callback) override; |
95 | 95 |
96 private: | 96 private: |
97 typedef std::map<std::string, int> AppIdToMessageCountMap; | 97 typedef std::map<std::string, int> AppIdToMessageCountMap; |
98 | 98 |
99 // Continuation to update the per-app message counts after a load. | 99 // Continuation to update the per-app message counts after a load. |
100 void LoadContinuation(const LoadCallback& callback, | 100 void LoadContinuation(const LoadCallback& callback, |
101 scoped_ptr<LoadResult> result); | 101 scoped_ptr<LoadResult> result); |
102 | 102 |
103 // Continuation to update the per-app message counts when adding messages. | 103 // Continuation to update the per-app message counts when adding messages. |
104 // In particular, if a message fails to add, the message count is decremented. | 104 // In particular, if a message fails to add, the message count is decremented. |
(...skipping 19 matching lines...) Expand all Loading... |
124 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 124 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
125 | 125 |
126 base::WeakPtrFactory<GCMStoreImpl> weak_ptr_factory_; | 126 base::WeakPtrFactory<GCMStoreImpl> weak_ptr_factory_; |
127 | 127 |
128 DISALLOW_COPY_AND_ASSIGN(GCMStoreImpl); | 128 DISALLOW_COPY_AND_ASSIGN(GCMStoreImpl); |
129 }; | 129 }; |
130 | 130 |
131 } // namespace gcm | 131 } // namespace gcm |
132 | 132 |
133 #endif // GOOGLE_APIS_GCM_ENGINE_GCM_STORE_IMPL_H_ | 133 #endif // GOOGLE_APIS_GCM_ENGINE_GCM_STORE_IMPL_H_ |
OLD | NEW |