Chromium Code Reviews| Index: components/gcm_driver/instance_id/instance_id_impl.cc |
| diff --git a/components/gcm_driver/instance_id/instance_id_impl.cc b/components/gcm_driver/instance_id/instance_id_impl.cc |
| index 4d76ad2286cde3fddb590f048170526d1b93b50c..3b2288dd1cf3dc107c883f3ecdacf4cdb6429c3c 100644 |
| --- a/components/gcm_driver/instance_id/instance_id_impl.cc |
| +++ b/components/gcm_driver/instance_id/instance_id_impl.cc |
| @@ -4,7 +4,11 @@ |
| #include "components/gcm_driver/instance_id/instance_id_impl.h" |
| +#include <algorithm> |
| +#include "base/bind.h" |
| +#include "base/guid.h" |
| #include "base/logging.h" |
| +#include "base/message_loop/message_loop.h" |
| namespace instance_id { |
| @@ -21,13 +25,12 @@ InstanceIDImpl::~InstanceIDImpl() { |
| } |
| std::string InstanceIDImpl::GetID() { |
| - NOTIMPLEMENTED(); |
| - return std::string(); |
| + EnsureIDGenerated(); |
| + return id_; |
| } |
| base::Time InstanceIDImpl::GetCreationTime() { |
| - NOTIMPLEMENTED(); |
| - return base::Time(); |
| + return creation_time_; |
| } |
| void InstanceIDImpl::GetToken( |
| @@ -45,7 +48,25 @@ void InstanceIDImpl::DeleteToken(const std::string& audience, |
| } |
| void InstanceIDImpl::DeleteID(const DeleteIDCallback& callback) { |
| - NOTIMPLEMENTED(); |
| + // TODO(jianli): Delete the ID from the store. |
| + id_.clear(); |
| + creation_time_ = base::Time(); |
| + |
| + base::MessageLoop::current()->PostTask( |
| + FROM_HERE, |
| + base::Bind(callback, this, InstanceID::SUCCESS)); |
| +} |
| + |
| +void InstanceIDImpl::EnsureIDGenerated() { |
| + if (!id_.empty()) |
| + return; |
| + |
| + id_ = base::GenerateGUID(); |
|
fgorski
2015/05/04 16:11:19
Based on the prior code, shouldn't you start from
jianli
2015/05/04 20:14:49
I've updated the ID generation algorithm based on
|
| + id_.erase(std::remove(id_.begin(), id_.end(), '-'), id_.end()); |
| + |
| + creation_time_ = base::Time::Now(); |
| + |
| + // TODO(jianli): Save the ID to the store. |
| } |
| } // namespace instance_id |