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

Unified Diff: components/gcm_driver/instance_id/instance_id_impl.h

Issue 1126233004: Persist Instance ID data to GCM store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mac Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/gcm_driver/instance_id/instance_id_impl.h
diff --git a/components/gcm_driver/instance_id/instance_id_impl.h b/components/gcm_driver/instance_id/instance_id_impl.h
index dd7b77524bafdcc349139aa25d83d741de7334be..a5124c1430c16148d0c08407e3e992d9ac703f3d 100644
--- a/components/gcm_driver/instance_id/instance_id_impl.h
+++ b/components/gcm_driver/instance_id/instance_id_impl.h
@@ -11,7 +11,9 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
+#include "components/gcm_driver/gcm_delayed_task_controller.h"
#include "components/gcm_driver/instance_id/instance_id.h"
namespace gcm {
@@ -27,8 +29,8 @@ class InstanceIDImpl : public InstanceID {
~InstanceIDImpl() override;
// InstanceID:
- std::string GetID() override;
- base::Time GetCreationTime() override;
+ void GetID(const GetIDCallback& callback) override;
+ void GetCreationTime(const GetCreationTimeCallback& callback) override;
void GetToken(const std::string& authorized_entity,
const std::string& scope,
const std::map<std::string, std::string>& options,
@@ -39,9 +41,22 @@ class InstanceIDImpl : public InstanceID {
void DeleteID(const DeleteIDCallback& callback) override;
private:
+ void EnsureIDGenerated();
+ void GetInstanceIDDataCompleted(const std::string& instance_id_data);
+
+ void DoGetID(const GetIDCallback& callback);
+ void DoGetCreationTime(const GetCreationTimeCallback& callback);
+
+ // Encodes/decodes the InstanceID data to work with the persistent store.
+ std::string SerializeAsString() const;
+ void Deserialize(const std::string& serialized_data);
+
gcm::GCMDriver* gcm_driver_; // Not owned.
- void EnsureIDGenerated();
+ gcm::GCMDelayedTaskController delayed_task_controller_;
+
+ // Flag to indicate that we have tries to load the data from the store.
+ bool load_from_store_;
// The generated Instance ID.
std::string id_;
@@ -49,6 +64,8 @@ class InstanceIDImpl : public InstanceID {
// The time when the Instance ID has been generated.
base::Time creation_time_;
+ base::WeakPtrFactory<InstanceIDImpl> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(InstanceIDImpl);
};

Powered by Google App Engine
This is Rietveld 408576698