| OLD | NEW |
| 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/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 10 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
| 11 #include "google_apis/gcm/protocol/checkin.pb.h" | 11 #include "google_apis/gcm/protocol/checkin.pb.h" |
| 12 #include "net/base/load_flags.h" |
| 12 #include "net/http/http_status_code.h" | 13 #include "net/http/http_status_code.h" |
| 13 #include "net/url_request/url_fetcher.h" | 14 #include "net/url_request/url_fetcher.h" |
| 14 #include "net/url_request/url_request_status.h" | 15 #include "net/url_request/url_request_status.h" |
| 15 | 16 |
| 16 namespace gcm { | 17 namespace gcm { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 const char kRequestContentType[] = "application/x-protobuf"; | 20 const char kRequestContentType[] = "application/x-protobuf"; |
| 20 const int kRequestVersionValue = 3; | 21 const int kRequestVersionValue = 3; |
| 21 const int kDefaultUserSerialNumber = 0; | 22 const int kDefaultUserSerialNumber = 0; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 checkin->set_type(checkin_proto::DEVICE_CHROME_BROWSER); | 128 checkin->set_type(checkin_proto::DEVICE_CHROME_BROWSER); |
| 128 #endif | 129 #endif |
| 129 | 130 |
| 130 std::string upload_data; | 131 std::string upload_data; |
| 131 CHECK(request.SerializeToString(&upload_data)); | 132 CHECK(request.SerializeToString(&upload_data)); |
| 132 | 133 |
| 133 url_fetcher_.reset( | 134 url_fetcher_.reset( |
| 134 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this)); | 135 net::URLFetcher::Create(checkin_url_, net::URLFetcher::POST, this)); |
| 135 url_fetcher_->SetRequestContext(request_context_getter_); | 136 url_fetcher_->SetRequestContext(request_context_getter_); |
| 136 url_fetcher_->SetUploadData(kRequestContentType, upload_data); | 137 url_fetcher_->SetUploadData(kRequestContentType, upload_data); |
| 138 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 139 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 137 recorder_->RecordCheckinInitiated(request_info_.android_id); | 140 recorder_->RecordCheckinInitiated(request_info_.android_id); |
| 138 request_start_time_ = base::TimeTicks::Now(); | 141 request_start_time_ = base::TimeTicks::Now(); |
| 139 url_fetcher_->Start(); | 142 url_fetcher_->Start(); |
| 140 } | 143 } |
| 141 | 144 |
| 142 void CheckinRequest::RetryWithBackoff(bool update_backoff) { | 145 void CheckinRequest::RetryWithBackoff(bool update_backoff) { |
| 143 if (update_backoff) { | 146 if (update_backoff) { |
| 144 backoff_entry_.InformOfRequest(false); | 147 backoff_entry_.InformOfRequest(false); |
| 145 url_fetcher_.reset(); | 148 url_fetcher_.reset(); |
| 146 } | 149 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 215 |
| 213 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); | 216 RecordCheckinStatusAndReportUMA(SUCCESS, recorder_, false); |
| 214 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", | 217 UMA_HISTOGRAM_COUNTS("GCM.CheckinRetryCount", |
| 215 backoff_entry_.failure_count()); | 218 backoff_entry_.failure_count()); |
| 216 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", | 219 UMA_HISTOGRAM_TIMES("GCM.CheckinCompleteTime", |
| 217 base::TimeTicks::Now() - request_start_time_); | 220 base::TimeTicks::Now() - request_start_time_); |
| 218 callback_.Run(response_proto); | 221 callback_.Run(response_proto); |
| 219 } | 222 } |
| 220 | 223 |
| 221 } // namespace gcm | 224 } // namespace gcm |
| OLD | NEW |