Update ASan/Android runtime and setup script to LLVM r200682.
[chromium-blink-merge.git] / google_apis / gcm / engine / gcm_store.h
blobed979499099e404d128f68f2382fbc7a9765c379
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.
5 #ifndef GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_
6 #define GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/callback_forward.h"
14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "google_apis/gcm/base/gcm_export.h"
18 #include "google_apis/gcm/protocol/mcs.pb.h"
20 namespace google {
21 namespace protobuf {
22 class MessageLite;
23 } // namespace protobuf
24 } // namespace google
26 namespace gcm {
28 class MCSMessage;
30 // A GCM data store interface. GCM Store will handle persistence portion of RMQ,
31 // as well as store device and user checkin information.
32 class GCM_EXPORT GCMStore {
33 public:
34 // Map of message id to message data for outgoing messages.
35 typedef std::map<std::string, linked_ptr<google::protobuf::MessageLite> >
36 OutgoingMessageMap;
38 // Part of load results storing user serial number mapping related values.
39 struct GCM_EXPORT SerialNumberMappings {
40 SerialNumberMappings();
41 ~SerialNumberMappings();
43 int64 next_serial_number;
44 std::map<std::string, int64> user_serial_numbers;
47 // Container for Load(..) results.
48 struct GCM_EXPORT LoadResult {
49 LoadResult();
50 ~LoadResult();
52 bool success;
53 uint64 device_android_id;
54 uint64 device_security_token;
55 std::vector<std::string> incoming_messages;
56 OutgoingMessageMap outgoing_messages;
57 SerialNumberMappings serial_number_mappings;
60 typedef std::vector<std::string> PersistentIdList;
61 typedef base::Callback<void(scoped_ptr<LoadResult> result)> LoadCallback;
62 typedef base::Callback<void(bool success)> UpdateCallback;
64 GCMStore();
65 virtual ~GCMStore();
67 // Load the data from persistent store and pass the initial state back to
68 // caller.
69 virtual void Load(const LoadCallback& callback) = 0;
71 // Clears the GCM store of all data.
72 virtual void Destroy(const UpdateCallback& callback) = 0;
74 // Sets this device's messaging credentials.
75 virtual void SetDeviceCredentials(uint64 device_android_id,
76 uint64 device_security_token,
77 const UpdateCallback& callback) = 0;
79 // Unacknowledged incoming message handling.
80 virtual void AddIncomingMessage(const std::string& persistent_id,
81 const UpdateCallback& callback) = 0;
82 virtual void RemoveIncomingMessage(const std::string& persistent_id,
83 const UpdateCallback& callback) = 0;
84 virtual void RemoveIncomingMessages(const PersistentIdList& persistent_ids,
85 const UpdateCallback& callback) = 0;
87 // Unacknowledged outgoing messages handling.
88 // Returns false if app has surpassed message limits, else returns true. Note
89 // that the message isn't persisted until |callback| is invoked with
90 // |success| == true.
91 virtual bool AddOutgoingMessage(const std::string& persistent_id,
92 const MCSMessage& message,
93 const UpdateCallback& callback) = 0;
94 virtual void RemoveOutgoingMessage(const std::string& persistent_id,
95 const UpdateCallback& callback) = 0;
96 virtual void RemoveOutgoingMessages(const PersistentIdList& persistent_ids,
97 const UpdateCallback& callback) = 0;
99 // User serial number handling.
100 virtual void SetNextSerialNumber(int64 next_serial_number,
101 const UpdateCallback& callback) = 0;
102 virtual void AddUserSerialNumber(const std::string& username,
103 int64 serial_number,
104 const UpdateCallback& callback) = 0;
105 virtual void RemoveUserSerialNumber(const std::string& username,
106 const UpdateCallback& callback) = 0;
108 private:
109 DISALLOW_COPY_AND_ASSIGN(GCMStore);
112 } // namespace gcm
114 #endif // GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_