| 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 "components/gcm_driver/gcm_channel_status_request.h" | 5 #include "components/gcm_driver/gcm_channel_status_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 11 #include "components/gcm_driver/gcm_backoff_policy.h" | 12 #include "components/gcm_driver/gcm_backoff_policy.h" |
| 12 #include "components/sync/protocol/experiment_status.pb.h" | 13 #include "components/sync/protocol/experiment_status.pb.h" |
| 13 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
| 14 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 15 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
| 16 #include "net/url_request/url_fetcher.h" | 17 #include "net/url_request/url_fetcher.h" |
| 17 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 namespace gcm { | 21 namespace gcm { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 62 |
| 62 sync_pb::ExperimentStatusRequest proto_data; | 63 sync_pb::ExperimentStatusRequest proto_data; |
| 63 proto_data.add_experiment_name(kGCMChannelTag); | 64 proto_data.add_experiment_name(kGCMChannelTag); |
| 64 std::string upload_data; | 65 std::string upload_data; |
| 65 if (!proto_data.SerializeToString(&upload_data)) { | 66 if (!proto_data.SerializeToString(&upload_data)) { |
| 66 NOTREACHED(); | 67 NOTREACHED(); |
| 67 } | 68 } |
| 68 | 69 |
| 69 url_fetcher_ = | 70 url_fetcher_ = |
| 70 net::URLFetcher::Create(request_url, net::URLFetcher::POST, this); | 71 net::URLFetcher::Create(request_url, net::URLFetcher::POST, this); |
| 72 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 73 url_fetcher_.get(), data_use_measurement::DataUseUserData::GCM_DRIVER); |
| 71 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 74 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
| 72 url_fetcher_->AddExtraRequestHeader("User-Agent: " + user_agent_); | 75 url_fetcher_->AddExtraRequestHeader("User-Agent: " + user_agent_); |
| 73 url_fetcher_->SetUploadData(kRequestContentType, upload_data); | 76 url_fetcher_->SetUploadData(kRequestContentType, upload_data); |
| 74 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 77 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 75 net::LOAD_DO_NOT_SAVE_COOKIES); | 78 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 76 url_fetcher_->Start(); | 79 url_fetcher_->Start(); |
| 77 } | 80 } |
| 78 | 81 |
| 79 void GCMChannelStatusRequest::OnURLFetchComplete( | 82 void GCMChannelStatusRequest::OnURLFetchComplete( |
| 80 const net::URLFetcher* source) { | 83 const net::URLFetcher* source) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 FROM_HERE, base::Bind(&GCMChannelStatusRequest::RetryWithBackoff, | 151 FROM_HERE, base::Bind(&GCMChannelStatusRequest::RetryWithBackoff, |
| 149 weak_ptr_factory_.GetWeakPtr(), false), | 152 weak_ptr_factory_.GetWeakPtr(), false), |
| 150 backoff_entry_.GetTimeUntilRelease()); | 153 backoff_entry_.GetTimeUntilRelease()); |
| 151 return; | 154 return; |
| 152 } | 155 } |
| 153 | 156 |
| 154 Start(); | 157 Start(); |
| 155 } | 158 } |
| 156 | 159 |
| 157 } // namespace gcm | 160 } // namespace gcm |
| OLD | NEW |