OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef GOOGLE_APIS_GCM_ENGINE_GCM_STORE_IMPL_H_ |
| 6 #define GOOGLE_APIS_GCM_ENGINE_GCM_STORE_IMPL_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "google_apis/gcm/base/gcm_export.h" |
| 11 #include "google_apis/gcm/engine/gcm_store.h" |
| 12 |
| 13 namespace base { |
| 14 class FilePath; |
| 15 class SequencedTaskRunner; |
| 16 } // namespace base |
| 17 |
| 18 namespace gcm { |
| 19 |
| 20 // An implementation of GCM Store that uses LevelDB for persistence. |
| 21 // It performs all blocking operations on the blocking task runner, and posts |
| 22 // all callbacks to the thread on which the GCMStoreImpl is created. |
| 23 class GCM_EXPORT GCMStoreImpl : public GCMStore { |
| 24 public: |
| 25 GCMStoreImpl(const base::FilePath& path, |
| 26 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); |
| 27 virtual ~GCMStoreImpl(); |
| 28 |
| 29 // Load the directory and pass the initial state back to caller. |
| 30 virtual void Load(const LoadCallback& callback) OVERRIDE; |
| 31 |
| 32 // Clears the GCM store of all data and destroys any LevelDB files associated |
| 33 // with this store. |
| 34 // WARNING: this will permanently destroy any pending outgoing messages |
| 35 // and require the device to re-create credentials and serial number mapping |
| 36 // tables. |
| 37 virtual void Destroy(const UpdateCallback& callback) OVERRIDE; |
| 38 |
| 39 // Sets this device's messaging credentials. |
| 40 virtual void SetDeviceCredentials(uint64 device_android_id, |
| 41 uint64 device_security_token, |
| 42 const UpdateCallback& callback) OVERRIDE; |
| 43 |
| 44 // Unacknowledged incoming message handling. |
| 45 virtual void AddIncomingMessage(const std::string& persistent_id, |
| 46 const UpdateCallback& callback) OVERRIDE; |
| 47 virtual void RemoveIncomingMessage(const std::string& persistent_id, |
| 48 const UpdateCallback& callback) OVERRIDE; |
| 49 virtual void RemoveIncomingMessages(const PersistentIdList& persistent_ids, |
| 50 const UpdateCallback& callback) OVERRIDE; |
| 51 |
| 52 // Unacknowledged outgoing messages handling. |
| 53 // TODO(zea): implement per-app limits on the number of outgoing messages. |
| 54 virtual void AddOutgoingMessage(const std::string& persistent_id, |
| 55 const MCSMessage& message, |
| 56 const UpdateCallback& callback) OVERRIDE; |
| 57 virtual void RemoveOutgoingMessage(const std::string& persistent_id, |
| 58 const UpdateCallback& callback) OVERRIDE; |
| 59 virtual void RemoveOutgoingMessages(const PersistentIdList& persistent_ids, |
| 60 const UpdateCallback& callback) OVERRIDE; |
| 61 |
| 62 // User serial number handling. |
| 63 virtual void SetNextSerialNumber(int64 next_serial_number, |
| 64 const UpdateCallback& callback) OVERRIDE; |
| 65 virtual void AddUserSerialNumber(const std::string& username, |
| 66 int64 serial_number, |
| 67 const UpdateCallback& callback) OVERRIDE; |
| 68 virtual void RemoveUserSerialNumber(const std::string& username, |
| 69 const UpdateCallback& callback) OVERRIDE; |
| 70 |
| 71 private: |
| 72 class Backend; |
| 73 |
| 74 scoped_refptr<Backend> backend_; |
| 75 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(GCMStoreImpl); |
| 78 }; |
| 79 |
| 80 } // namespace gcm |
| 81 |
| 82 #endif // GOOGLE_APIS_GCM_ENGINE_GCM_STORE_IMPL_H_ |
OLD | NEW |