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

Side by Side Diff: google_apis/gcm/engine/checkin_request.cc

Issue 1232193002: Replace MessageLoop::current() with ThreadTaskRunnerHandle::Get() in GCM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "google_apis/gcm/engine/checkin_request.h" 5 #include "google_apis/gcm/engine/checkin_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/location.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/thread_task_runner_handle.h"
10 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" 11 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
11 #include "google_apis/gcm/protocol/checkin.pb.h" 12 #include "google_apis/gcm/protocol/checkin.pb.h"
12 #include "net/base/load_flags.h" 13 #include "net/base/load_flags.h"
13 #include "net/http/http_status_code.h" 14 #include "net/http/http_status_code.h"
14 #include "net/url_request/url_fetcher.h" 15 #include "net/url_request/url_fetcher.h"
15 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
16 17
17 namespace gcm { 18 namespace gcm {
18 19
19 namespace { 20 namespace {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 backoff_entry_.InformOfRequest(false); 160 backoff_entry_.InformOfRequest(false);
160 url_fetcher_.reset(); 161 url_fetcher_.reset();
161 } 162 }
162 163
163 if (backoff_entry_.ShouldRejectRequest()) { 164 if (backoff_entry_.ShouldRejectRequest()) {
164 DVLOG(1) << "Delay GCM checkin for: " 165 DVLOG(1) << "Delay GCM checkin for: "
165 << backoff_entry_.GetTimeUntilRelease().InMilliseconds() 166 << backoff_entry_.GetTimeUntilRelease().InMilliseconds()
166 << " milliseconds."; 167 << " milliseconds.";
167 recorder_->RecordCheckinDelayedDueToBackoff( 168 recorder_->RecordCheckinDelayedDueToBackoff(
168 backoff_entry_.GetTimeUntilRelease().InMilliseconds()); 169 backoff_entry_.GetTimeUntilRelease().InMilliseconds());
169 base::MessageLoop::current()->PostDelayedTask( 170 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
170 FROM_HERE, 171 FROM_HERE,
171 base::Bind(&CheckinRequest::RetryWithBackoff, 172 base::Bind(&CheckinRequest::RetryWithBackoff,
172 weak_ptr_factory_.GetWeakPtr(), 173 weak_ptr_factory_.GetWeakPtr(),
173 false), 174 false),
174 backoff_entry_.GetTimeUntilRelease()); 175 backoff_entry_.GetTimeUntilRelease());
175 return; 176 return;
176 } 177 }
177 178
178 Start(); 179 Start();
179 } 180 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 228
228 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); 229 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false);
229 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", 230 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount",
230 backoff_entry_.failure_count()); 231 backoff_entry_.failure_count());
231 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", 232 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime",
232 base::TimeTicks::Now() - request_start_time_); 233 base::TimeTicks::Now() - request_start_time_);
233 callback_.Run(response_proto); 234 callback_.Run(response_proto);
234 } 235 }
235 236
236 } // namespace gcm 237 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698