Chromium Code Reviews| 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/data_use_measurement/core/data_use_user_data.h" |
| 12 #include "components/gcm_driver/gcm_backoff_policy.h" | 12 #include "components/gcm_driver/gcm_backoff_policy.h" |
| 13 #include "components/sync/protocol/experiment_status.pb.h" | 13 #include "components/sync/protocol/experiment_status.pb.h" |
| 14 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
| 15 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 16 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
| 17 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 17 #include "net/url_request/url_fetcher.h" | 18 #include "net/url_request/url_fetcher.h" |
| 18 #include "net/url_request/url_request_status.h" | 19 #include "net/url_request/url_request_status.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| 21 namespace gcm { | 22 namespace gcm { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 const char kRequestContentType[] = "application/octet-stream"; | 26 const char kRequestContentType[] = "application/octet-stream"; |
| 26 const char kGCMChannelTag[] = "gcm_channel"; | 27 const char kGCMChannelTag[] = "gcm_channel"; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 61 |
| 61 GURL request_url(channel_status_request_url_); | 62 GURL request_url(channel_status_request_url_); |
| 62 | 63 |
| 63 sync_pb::ExperimentStatusRequest proto_data; | 64 sync_pb::ExperimentStatusRequest proto_data; |
| 64 proto_data.add_experiment_name(kGCMChannelTag); | 65 proto_data.add_experiment_name(kGCMChannelTag); |
| 65 std::string upload_data; | 66 std::string upload_data; |
| 66 if (!proto_data.SerializeToString(&upload_data)) { | 67 if (!proto_data.SerializeToString(&upload_data)) { |
| 67 NOTREACHED(); | 68 NOTREACHED(); |
| 68 } | 69 } |
| 69 | 70 |
| 70 url_fetcher_ = | 71 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 71 net::URLFetcher::Create(request_url, net::URLFetcher::POST, this); | 72 net::DefineNetworkTrafficAnnotation("...", R"( |
|
Peter Beverloo
2017/02/21 14:04:13
gcm_channel_status_request
Ramin Halavati
2017/02/21 14:17:50
Done.
| |
| 73 semantics { | |
|
Peter Beverloo
2017/02/21 14:04:13
semantics {
sender: "gcm_driver"
description:
Ramin Halavati
2017/02/21 14:17:50
Done.
| |
| 74 sender: "..." | |
| 75 description: "..." | |
| 76 trigger: "..." | |
| 77 data: "..." | |
| 78 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
| 79 } | |
| 80 policy { | |
| 81 cookies_allowed: false/true | |
| 82 cookies_store: "..." | |
| 83 setting: "..." | |
| 84 policy { | |
| 85 [POLICY_NAME] { | |
| 86 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 87 value: ... | |
| 88 } | |
| 89 } | |
| 90 policy_exception_justification: "..." | |
| 91 })"); | |
| 92 | |
| 93 url_fetcher_ = net::URLFetcher::Create(request_url, net::URLFetcher::POST, | |
| 94 this, traffic_annotation); | |
| 72 data_use_measurement::DataUseUserData::AttachToFetcher( | 95 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 73 url_fetcher_.get(), data_use_measurement::DataUseUserData::GCM_DRIVER); | 96 url_fetcher_.get(), data_use_measurement::DataUseUserData::GCM_DRIVER); |
| 74 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 97 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
| 75 url_fetcher_->AddExtraRequestHeader("User-Agent: " + user_agent_); | 98 url_fetcher_->AddExtraRequestHeader("User-Agent: " + user_agent_); |
| 76 url_fetcher_->SetUploadData(kRequestContentType, upload_data); | 99 url_fetcher_->SetUploadData(kRequestContentType, upload_data); |
| 77 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 100 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 78 net::LOAD_DO_NOT_SAVE_COOKIES); | 101 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 79 url_fetcher_->Start(); | 102 url_fetcher_->Start(); |
| 80 } | 103 } |
| 81 | 104 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 FROM_HERE, base::Bind(&GCMChannelStatusRequest::RetryWithBackoff, | 174 FROM_HERE, base::Bind(&GCMChannelStatusRequest::RetryWithBackoff, |
| 152 weak_ptr_factory_.GetWeakPtr(), false), | 175 weak_ptr_factory_.GetWeakPtr(), false), |
| 153 backoff_entry_.GetTimeUntilRelease()); | 176 backoff_entry_.GetTimeUntilRelease()); |
| 154 return; | 177 return; |
| 155 } | 178 } |
| 156 | 179 |
| 157 Start(); | 180 Start(); |
| 158 } | 181 } |
| 159 | 182 |
| 160 } // namespace gcm | 183 } // namespace gcm |
| OLD | NEW |