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

Unified Diff: components/gcm_driver/gcm_client_impl.cc

Issue 1096983002: Update usages of std::map to use ScopedPtrMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passwordmanager-scopedmemory
Patch Set: Fix Mac compile. Created 5 years, 6 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/gcm_client_impl.cc
diff --git a/components/gcm_driver/gcm_client_impl.cc b/components/gcm_driver/gcm_client_impl.cc
index 8ffc695423222f7ffd6877f1e902d442b354b52d..e046aefc20194985d4ff9b977e2a9a366835d3f8 100644
--- a/components/gcm_driver/gcm_client_impl.cc
+++ b/components/gcm_driver/gcm_client_impl.cc
@@ -301,9 +301,6 @@ GCMClientImpl::GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder)
clock_(internals_builder_->BuildClock()),
gcm_store_reset_(false),
url_request_context_getter_(NULL),
- pending_registration_requests_deleter_(&pending_registration_requests_),
- pending_unregistration_requests_deleter_(
- &pending_unregistration_requests_),
periodic_checkin_ptr_factory_(this),
destroying_gcm_store_ptr_factory_(this),
weak_ptr_factory_(this) {
@@ -838,8 +835,8 @@ void GCMClientImpl::ResetCache() {
mcs_client_.reset();
checkin_request_.reset();
// Delete all of the pending registration and unregistration requests.
- STLDeleteValues(&pending_registration_requests_);
- STLDeleteValues(&pending_unregistration_requests_);
+ pending_registration_requests_.clear();
+ pending_unregistration_requests_.clear();
}
void GCMClientImpl::Register(
@@ -916,20 +913,16 @@ void GCMClientImpl::Register(
device_checkin_info_.secret,
registration_info->app_id);
- RegistrationRequest* registration_request =
- new RegistrationRequest(gservices_settings_.GetRegistrationURL(),
- request_info,
- request_handler.Pass(),
- GetGCMBackoffPolicy(),
- base::Bind(&GCMClientImpl::OnRegisterCompleted,
- weak_ptr_factory_.GetWeakPtr(),
- registration_info),
- kMaxRegistrationRetries,
- url_request_context_getter_,
- &recorder_,
- source_to_record);
- pending_registration_requests_[registration_info] = registration_request;
+ scoped_ptr<RegistrationRequest> registration_request(new RegistrationRequest(
+ gservices_settings_.GetRegistrationURL(), request_info,
+ request_handler.Pass(), GetGCMBackoffPolicy(),
+ base::Bind(&GCMClientImpl::OnRegisterCompleted,
+ weak_ptr_factory_.GetWeakPtr(), registration_info),
+ kMaxRegistrationRetries, url_request_context_getter_, &recorder_,
+ source_to_record));
registration_request->Start();
+ pending_registration_requests_.insert(registration_info,
+ registration_request.Pass());
}
void GCMClientImpl::OnRegisterCompleted(
@@ -939,7 +932,7 @@ void GCMClientImpl::OnRegisterCompleted(
DCHECK(delegate_);
Result result;
- PendingRegistrationRequests::iterator iter =
+ PendingRegistrationRequests::const_iterator iter =
pending_registration_requests_.find(registration_info);
if (iter == pending_registration_requests_.end())
result = UNKNOWN_ERROR;
@@ -967,10 +960,8 @@ void GCMClientImpl::OnRegisterCompleted(
result == SUCCESS ? registration_id : std::string(),
result);
- if (iter != pending_registration_requests_.end()) {
- delete iter->second;
+ if (iter != pending_registration_requests_.end())
pending_registration_requests_.erase(iter);
- }
}
void GCMClientImpl::Unregister(
@@ -1042,18 +1033,16 @@ void GCMClientImpl::Unregister(
device_checkin_info_.secret,
registration_info->app_id);
- UnregistrationRequest* unregistration_request = new UnregistrationRequest(
- gservices_settings_.GetRegistrationURL(),
- request_info,
- request_handler.Pass(),
- GetGCMBackoffPolicy(),
- base::Bind(&GCMClientImpl::OnUnregisterCompleted,
- weak_ptr_factory_.GetWeakPtr(),
- registration_info),
- url_request_context_getter_,
- &recorder_);
- pending_unregistration_requests_[registration_info] = unregistration_request;
+ scoped_ptr<UnregistrationRequest> unregistration_request(
+ new UnregistrationRequest(
+ gservices_settings_.GetRegistrationURL(), request_info,
+ request_handler.Pass(), GetGCMBackoffPolicy(),
+ base::Bind(&GCMClientImpl::OnUnregisterCompleted,
+ weak_ptr_factory_.GetWeakPtr(), registration_info),
+ url_request_context_getter_, &recorder_));
unregistration_request->Start();
+ pending_unregistration_requests_.insert(registration_info,
+ unregistration_request.Pass());
}
void GCMClientImpl::OnUnregisterCompleted(
@@ -1065,13 +1054,7 @@ void GCMClientImpl::OnUnregisterCompleted(
registration_info,
status == UnregistrationRequest::SUCCESS ? SUCCESS : SERVER_ERROR);
- PendingUnregistrationRequests::iterator iter =
- pending_unregistration_requests_.find(registration_info);
- if (iter == pending_unregistration_requests_.end())
- return;
-
- delete iter->second;
- pending_unregistration_requests_.erase(iter);
+ pending_unregistration_requests_.erase(registration_info);
}
void GCMClientImpl::OnGCMStoreDestroyed(bool success) {

Powered by Google App Engine
This is Rietveld 408576698