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("gcm_channel_status_request", R"( |
| 73 semantics { |
| 74 sender: "GCM Driver" |
| 75 description: |
| 76 "Google Chrome interacts with Google Cloud Messaging to receive " |
| 77 "push messages for various browser features, as well as on behalf " |
| 78 "of websites and extensions. The channel status request " |
| 79 "periodically confirms with Google servers whether the feature " |
| 80 "should be enabled." |
| 81 trigger: |
| 82 "Periodically when Chrome has established an active Google Cloud " |
| 83 "Messaging subscription. The first request will be issued a minute " |
| 84 "after the first subscription activates. Subsequent requests will " |
| 85 "be issued each hour with a jitter of 15 minutes. Google can " |
| 86 "adjust this interval when it deems necessary." |
| 87 data: |
| 88 "A user agent string containing the Chrome version, channel and " |
| 89 "platform will be sent to the server. No user identifier is sent " |
| 90 "along with the request." |
| 91 destination: GOOGLE_OWNED_SERVICE |
| 92 } |
| 93 policy { |
| 94 cookies_allowed: false |
| 95 setting: |
| 96 "Support for interacting with Google Cloud Messaging is enabled by " |
| 97 "default, and there is no configuration option to completely " |
| 98 "disable it. Websites wishing to receive push messages must " |
| 99 "acquire express permission from the user for the 'Notification' " |
| 100 "permission." |
| 101 policy_exception_justification: |
| 102 "Not implemented, considered not useful." |
| 103 })"); |
| 104 |
| 105 url_fetcher_ = net::URLFetcher::Create(request_url, net::URLFetcher::POST, |
| 106 this, traffic_annotation); |
72 data_use_measurement::DataUseUserData::AttachToFetcher( | 107 data_use_measurement::DataUseUserData::AttachToFetcher( |
73 url_fetcher_.get(), data_use_measurement::DataUseUserData::GCM_DRIVER); | 108 url_fetcher_.get(), data_use_measurement::DataUseUserData::GCM_DRIVER); |
74 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 109 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
75 url_fetcher_->AddExtraRequestHeader("User-Agent: " + user_agent_); | 110 url_fetcher_->AddExtraRequestHeader("User-Agent: " + user_agent_); |
76 url_fetcher_->SetUploadData(kRequestContentType, upload_data); | 111 url_fetcher_->SetUploadData(kRequestContentType, upload_data); |
77 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 112 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
78 net::LOAD_DO_NOT_SAVE_COOKIES); | 113 net::LOAD_DO_NOT_SAVE_COOKIES); |
79 url_fetcher_->Start(); | 114 url_fetcher_->Start(); |
80 } | 115 } |
81 | 116 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 FROM_HERE, base::Bind(&GCMChannelStatusRequest::RetryWithBackoff, | 186 FROM_HERE, base::Bind(&GCMChannelStatusRequest::RetryWithBackoff, |
152 weak_ptr_factory_.GetWeakPtr(), false), | 187 weak_ptr_factory_.GetWeakPtr(), false), |
153 backoff_entry_.GetTimeUntilRelease()); | 188 backoff_entry_.GetTimeUntilRelease()); |
154 return; | 189 return; |
155 } | 190 } |
156 | 191 |
157 Start(); | 192 Start(); |
158 } | 193 } |
159 | 194 |
160 } // namespace gcm | 195 } // namespace gcm |
OLD | NEW |