diff options
author | jianli <jianli@chromium.org> | 2015-05-11 14:14:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-11 21:14:58 +0000 |
commit | 10018b2d2d5954cb697ccad19eef63919aef0786 (patch) | |
tree | 7f5f4fa86eacf75884463c87438ddfe84b1fd4f1 /components/gcm_driver/instance_id/instance_id_impl.h | |
parent | e8624082aaf1743e46f2868f807ac164c587d77b (diff) | |
download | chromium_src-10018b2d2d5954cb697ccad19eef63919aef0786.zip chromium_src-10018b2d2d5954cb697ccad19eef63919aef0786.tar.gz chromium_src-10018b2d2d5954cb697ccad19eef63919aef0786.tar.bz2 |
Persist Instance ID data to GCM store.
BUG=477084
TEST=new tests
TBR=asvitkine@chromium.org
Review URL: https://codereview.chromium.org/1126233004
Cr-Commit-Position: refs/heads/master@{#329233}
Diffstat (limited to 'components/gcm_driver/instance_id/instance_id_impl.h')
-rw-r--r-- | components/gcm_driver/instance_id/instance_id_impl.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/components/gcm_driver/instance_id/instance_id_impl.h b/components/gcm_driver/instance_id/instance_id_impl.h index dd7b775..a5124c1 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); }; |