Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / google_apis / gcm / engine / gcm_store.h
index ed97949..9bad954 100644 (file)
@@ -6,22 +6,21 @@
 #define GOOGLE_APIS_GCM_ENGINE_GCM_STORE_H_
 
 #include <map>
+#include <set>
 #include <string>
 #include <vector>
 
+#include <google/protobuf/message_lite.h>
+
 #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/protocol/mcs.pb.h"
-
-namespace google {
-namespace protobuf {
-class MessageLite;
-}  // namespace protobuf
-}  // namespace google
+#include "google_apis/gcm/engine/account_mapping.h"
+#include "google_apis/gcm/engine/registration_info.h"
 
 namespace gcm {
 
@@ -35,26 +34,28 @@ class GCM_EXPORT GCMStore {
   typedef std::map<std::string, linked_ptr<google::protobuf::MessageLite> >
       OutgoingMessageMap;
 
-  // Part of load results storing user serial number mapping related values.
-  struct GCM_EXPORT SerialNumberMappings {
-    SerialNumberMappings();
-    ~SerialNumberMappings();
-
-    int64 next_serial_number;
-    std::map<std::string, int64> user_serial_numbers;
-  };
+  // List of account mappings.
+  typedef std::vector<AccountMapping> AccountMappings;
 
   // Container for Load(..) results.
   struct GCM_EXPORT LoadResult {
     LoadResult();
     ~LoadResult();
 
+    void Reset();
+
     bool success;
     uint64 device_android_id;
     uint64 device_security_token;
+    RegistrationInfoMap registrations;
     std::vector<std::string> incoming_messages;
     OutgoingMessageMap outgoing_messages;
-    SerialNumberMappings serial_number_mappings;
+    std::map<std::string, std::string> gservices_settings;
+    std::string gservices_digest;
+    base::Time last_checkin_time;
+    std::set<std::string> last_checkin_accounts;
+    AccountMappings account_mappings;
+    base::Time last_token_fetch_time;
   };
 
   typedef std::vector<std::string> PersistentIdList;
@@ -68,6 +69,9 @@ class GCM_EXPORT GCMStore {
   // caller.
   virtual void Load(const LoadCallback& callback) = 0;
 
+  // Close the persistent store.
+  virtual void Close() = 0;
+
   // Clears the GCM store of all data.
   virtual void Destroy(const UpdateCallback& callback) = 0;
 
@@ -76,6 +80,13 @@ class GCM_EXPORT GCMStore {
                                     uint64 device_security_token,
                                     const UpdateCallback& callback) = 0;
 
+  // Registration info.
+  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;
+
   // Unacknowledged incoming message handling.
   virtual void AddIncomingMessage(const std::string& persistent_id,
                                   const UpdateCallback& callback) = 0;
@@ -91,19 +102,36 @@ class GCM_EXPORT GCMStore {
   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;
 
-  // User serial number handling.
-  virtual void SetNextSerialNumber(int64 next_serial_number,
-                                   const UpdateCallback& callback) = 0;
-  virtual void AddUserSerialNumber(const std::string& username,
-                                   int64 serial_number,
-                                   const UpdateCallback& callback) = 0;
-  virtual void RemoveUserSerialNumber(const std::string& username,
-                                      const UpdateCallback& callback) = 0;
+  // Sets last device's checkin information.
+  virtual void SetLastCheckinInfo(const base::Time& time,
+                                  const std::set<std::string>& accounts,
+                                  const UpdateCallback& callback) = 0;
+
+  // G-service settings handling.
+  // Persists |settings| and |settings_digest|. It completely replaces the
+  // existing data.
+  virtual void SetGServicesSettings(
+      const std::map<std::string, std::string>& settings,
+      const std::string& settings_digest,
+      const UpdateCallback& callback) = 0;
+
+  // Sets the account information related to device to account mapping.
+  virtual void AddAccountMapping(const AccountMapping& account_mapping,
+                                 const UpdateCallback& callback) = 0;
+  virtual void RemoveAccountMapping(const std::string& account_id,
+                                    const UpdateCallback& callback) = 0;
+
+  // Sets last token fetch time.
+  virtual void SetLastTokenFetchTime(const base::Time& time,
+                                     const UpdateCallback& callback) = 0;
 
  private:
   DISALLOW_COPY_AND_ASSIGN(GCMStore);