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

Side by Side Diff: google_apis/gcm/engine/rmq_store.h

Issue 121743002: Renaming RMQStore to GCMStore and breaking out its interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding a GCM_EXPORT directive to GCMStoreImpl Created 6 years, 11 months 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
« no previous file with comments | « google_apis/gcm/engine/mcs_client_unittest.cc ('k') | google_apis/gcm/engine/rmq_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_RMQ_STORE_H_
6 #define GOOGLE_APIS_GCM_ENGINE_RMQ_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 base {
18 class FilePath;
19 class SequencedTaskRunner;
20 } // namespace base
21
22 namespace google {
23 namespace protobuf {
24 class MessageLite;
25 } // namespace protobuf
26 } // namespace google
27
28 namespace gcm {
29
30 class MCSMessage;
31
32 // A Reliable Message Queue store.
33 // Will perform all blocking operations on the blocking task runner, and will
34 // post all callbacks to the thread on which the RMQStore is created.
35 class GCM_EXPORT RMQStore {
36 public:
37 // Container for Load(..) results.
38 struct GCM_EXPORT LoadResult {
39 LoadResult();
40 ~LoadResult();
41
42 bool success;
43 uint64 device_android_id;
44 uint64 device_security_token;
45 std::vector<std::string> incoming_messages;
46 std::map<std::string, google::protobuf::MessageLite*>
47 outgoing_messages;
48 int64 next_serial_number;
49 std::map<std::string, int64> user_serial_numbers;
50 };
51
52 typedef std::vector<std::string> PersistentIdList;
53 // Note: callee receives ownership of |outgoing_messages|' values.
54 typedef base::Callback<void(const LoadResult& result)> LoadCallback;
55 typedef base::Callback<void(bool success)> UpdateCallback;
56
57 RMQStore(const base::FilePath& path,
58 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
59 ~RMQStore();
60
61 // Load the directory and pass the initial state back to caller.
62 void Load(const LoadCallback& callback);
63
64 // Clears the RMQ store of all data and destroys any LevelDB files associated
65 // with this store.
66 // WARNING: this will permanently destroy any pending outgoing messages
67 // and require the device to re-create credentials.
68 void Destroy(const UpdateCallback& callback);
69
70 // Sets this device's messaging credentials.
71 void SetDeviceCredentials(uint64 device_android_id,
72 uint64 device_security_token,
73 const UpdateCallback& callback);
74
75 // Unacknowledged incoming message handling.
76 void AddIncomingMessage(const std::string& persistent_id,
77 const UpdateCallback& callback);
78 void RemoveIncomingMessage(const std::string& persistent_id,
79 const UpdateCallback& callback);
80 void RemoveIncomingMessages(const PersistentIdList& persistent_ids,
81 const UpdateCallback& callback);
82
83 // Unacknowledged outgoing messages handling.
84 // TODO(zea): implement per-app limits on the number of outgoing messages.
85 void AddOutgoingMessage(const std::string& persistent_id,
86 const MCSMessage& message,
87 const UpdateCallback& callback);
88 void RemoveOutgoingMessage(const std::string& persistent_id,
89 const UpdateCallback& callback);
90 void RemoveOutgoingMessages(const PersistentIdList& persistent_ids,
91 const UpdateCallback& callback);
92
93 // User serial number handling.
94 void SetNextSerialNumber(int64 next_serial_number,
95 const UpdateCallback& callback);
96 void AddUserSerialNumber(const std::string& username,
97 int64 serial_number,
98 const UpdateCallback& callback);
99 void RemoveUserSerialNumber(const std::string& username,
100 const UpdateCallback& callback);
101
102 private:
103 class Backend;
104
105 scoped_refptr<Backend> backend_;
106 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
107
108 DISALLOW_COPY_AND_ASSIGN(RMQStore);
109 };
110
111 } // namespace gcm
112
113 #endif // GOOGLE_APIS_GCM_ENGINE_RMQ_STORE_H_
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/mcs_client_unittest.cc ('k') | google_apis/gcm/engine/rmq_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698