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

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

Issue 1923953002: Integrate InstanceID with GCM crypto provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid5default
Patch Set: RunUntilIdle after deleting GCMDriver Created 4 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
« no previous file with comments | « components/gcm_driver/instance_id/instance_id_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 667008fdd2622eb341e7a1e01f8ad02ce97ebcf5..74c708a560ac0f07ae46f9e6bb3b6a89d5076b30 100644
--- a/components/gcm_driver/instance_id/instance_id_impl.cc
+++ b/components/gcm_driver/instance_id/instance_id_impl.cc
@@ -49,17 +49,15 @@ InstanceID::Result GCMClientResultToInstanceIDResult(
} // namespace
// static
-std::unique_ptr<InstanceID> InstanceID::Create(
- const std::string& app_id,
- gcm::InstanceIDHandler* handler) {
- return base::WrapUnique(new InstanceIDImpl(app_id, handler));
+std::unique_ptr<InstanceID> InstanceID::Create(const std::string& app_id,
+ gcm::GCMDriver* gcm_driver) {
+ return base::WrapUnique(new InstanceIDImpl(app_id, gcm_driver));
}
InstanceIDImpl::InstanceIDImpl(const std::string& app_id,
- gcm::InstanceIDHandler* handler)
- : InstanceID(app_id), handler_(handler), weak_ptr_factory_(this) {
- DCHECK(handler_);
- handler_->GetInstanceIDData(
+ gcm::GCMDriver* gcm_driver)
+ : InstanceID(app_id, gcm_driver), weak_ptr_factory_(this) {
+ Handler()->GetInstanceIDData(
app_id, base::Bind(&InstanceIDImpl::GetInstanceIDDataCompleted,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -130,14 +128,14 @@ void InstanceIDImpl::DoGetToken(
const GetTokenCallback& callback) {
EnsureIDGenerated();
- handler_->GetToken(app_id(), authorized_entity, scope, options,
- base::Bind(&InstanceIDImpl::OnGetTokenCompleted,
- weak_ptr_factory_.GetWeakPtr(), callback));
+ Handler()->GetToken(app_id(), authorized_entity, scope, options,
+ base::Bind(&InstanceIDImpl::OnGetTokenCompleted,
+ weak_ptr_factory_.GetWeakPtr(), callback));
}
-void InstanceIDImpl::DeleteToken(const std::string& authorized_entity,
- const std::string& scope,
- const DeleteTokenCallback& callback) {
+void InstanceIDImpl::DeleteTokenImpl(const std::string& authorized_entity,
+ const std::string& scope,
+ const DeleteTokenCallback& callback) {
DCHECK(!authorized_entity.empty());
DCHECK(!scope.empty());
@@ -164,12 +162,12 @@ void InstanceIDImpl::DoDeleteToken(
return;
}
- handler_->DeleteToken(app_id(), authorized_entity, scope,
+ Handler()->DeleteToken(app_id(), authorized_entity, scope,
base::Bind(&InstanceIDImpl::OnDeleteTokenCompleted,
weak_ptr_factory_.GetWeakPtr(), callback));
}
-void InstanceIDImpl::DeleteID(const DeleteIDCallback& callback) {
+void InstanceIDImpl::DeleteIDImpl(const DeleteIDCallback& callback) {
if (!delayed_task_controller_.CanRunTaskWithoutDelay()) {
delayed_task_controller_.AddTask(
base::Bind(&InstanceIDImpl::DoDeleteID,
@@ -188,11 +186,11 @@ void InstanceIDImpl::DoDeleteID(const DeleteIDCallback& callback) {
return;
}
- handler_->DeleteAllTokensForApp(
+ Handler()->DeleteAllTokensForApp(
app_id(), base::Bind(&InstanceIDImpl::OnDeleteIDCompleted,
weak_ptr_factory_.GetWeakPtr(), callback));
- handler_->RemoveInstanceIDData(app_id());
+ Handler()->RemoveInstanceIDData(app_id());
id_.clear();
creation_time_ = base::Time();
@@ -265,8 +263,15 @@ void InstanceIDImpl::EnsureIDGenerated() {
creation_time_ = base::Time::Now();
// Save to the persistent store.
- handler_->AddInstanceIDData(
+ Handler()->AddInstanceIDData(
app_id(), id_, base::Int64ToString(creation_time_.ToInternalValue()));
}
+gcm::InstanceIDHandler* InstanceIDImpl::Handler() {
+ gcm::InstanceIDHandler* handler =
+ gcm_driver()->GetInstanceIDHandlerInternal();
+ DCHECK(handler);
+ return handler;
+}
+
} // namespace instance_id
« no previous file with comments | « components/gcm_driver/instance_id/instance_id_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698