#ifndef GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_
#define GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_
#include <map>
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "google_apis/gcm/base/gcm_export.h"
#include "google_apis/gcm/engine/registration_info.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
namespace google {
namespace protobuf {
class MessageLite;
}
}
namespace gcm {
class MCSMessage;
class GCM_EXPORT GCMStore {
public:
typedef std::map<std::string, linked_ptr<google::protobuf::MessageLite> >
OutgoingMessageMap;
struct GCM_EXPORT LoadResult {
LoadResult();
~LoadResult();
bool success;
uint64 device_android_id;
uint64 device_security_token;
RegistrationInfoMap registrations;
std::vector<std::string> incoming_messages;
OutgoingMessageMap outgoing_messages;
base::Time last_checkin_time;
};
typedef std::vector<std::string> PersistentIdList;
typedef base::Callback<void(scoped_ptr<LoadResult> result)> LoadCallback;
typedef base::Callback<void(bool success)> UpdateCallback;
GCMStore();
virtual ~GCMStore();
virtual void Load(const LoadCallback& callback) = 0;
virtual void Close() = 0;
virtual void Destroy(const UpdateCallback& callback) = 0;
virtual void SetDeviceCredentials(uint64 device_android_id,
uint64 device_security_token,
const UpdateCallback& callback) = 0;
virtual void AddRegistration(const std::string& app_id,
const linked_ptr<RegistrationInfo>& registration,
const UpdateCallback& callback) = 0;
virtual void RemoveRegistration(const std::string& app_id,
const UpdateCallback& callback) = 0;
virtual void AddIncomingMessage(const std::string& persistent_id,
const UpdateCallback& callback) = 0;
virtual void RemoveIncomingMessage(const std::string& persistent_id,
const UpdateCallback& callback) = 0;
virtual void RemoveIncomingMessages(const PersistentIdList& persistent_ids,
const UpdateCallback& callback) = 0;
virtual bool AddOutgoingMessage(const std::string& persistent_id,
const MCSMessage& message,
const UpdateCallback& callback) = 0;
virtual void OverwriteOutgoingMessage(const std::string& persistent_id,
const MCSMessage& message,
const UpdateCallback& callback) = 0;
virtual void RemoveOutgoingMessage(const std::string& persistent_id,
const UpdateCallback& callback) = 0;
virtual void RemoveOutgoingMessages(const PersistentIdList& persistent_ids,
const UpdateCallback& callback) = 0;
virtual void SetLastCheckinTime(const base::Time& last_checkin_time,
const UpdateCallback& callback) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(GCMStore);
};
}
#endif