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

Side by Side Diff: remoting/protocol/port_allocator.cc

Issue 2729423003: Network traffic annotation added to chromium_url_request. (Closed)
Patch Set: Annotation updated. Created 3 years, 7 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
« no previous file with comments | « remoting/protocol/http_ice_config_request_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/protocol/port_allocator.h" 5 #include "remoting/protocol/port_allocator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "net/base/escape.h" 14 #include "net/base/escape.h"
15 #include "net/http/http_status_code.h" 15 #include "net/http/http_status_code.h"
16 #include "net/traffic_annotation/network_traffic_annotation.h"
16 #include "remoting/protocol/network_settings.h" 17 #include "remoting/protocol/network_settings.h"
17 #include "remoting/protocol/transport_context.h" 18 #include "remoting/protocol/transport_context.h"
18 19
19 namespace { 20 namespace {
20 21
21 typedef std::map<std::string, std::string> StringMap; 22 typedef std::map<std::string, std::string> StringMap;
22 23
23 // Parses the lines in the result of the HTTP request that are of the form 24 // Parses the lines in the result of the HTTP request that are of the form
24 // 'a=b' and returns them in a map. 25 // 'a=b' and returns them in a map.
25 StringMap ParseMap(const std::string& string) { 26 StringMap ParseMap(const std::string& string) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 std::string host = 144 std::string host =
144 ice_config_.relay_servers[attempts_ % ice_config_.relay_servers.size()]; 145 ice_config_.relay_servers[attempts_ % ice_config_.relay_servers.size()];
145 attempts_++; 146 attempts_++;
146 147
147 DCHECK(!username().empty()); 148 DCHECK(!username().empty());
148 DCHECK(!password().empty()); 149 DCHECK(!password().empty());
149 std::string url = "https://" + host + "/create_session?username=" + 150 std::string url = "https://" + host + "/create_session?username=" +
150 net::EscapeUrlEncodedData(username(), false) + 151 net::EscapeUrlEncodedData(username(), false) +
151 "&password=" + 152 "&password=" +
152 net::EscapeUrlEncodedData(password(), false) + "&sn=1"; 153 net::EscapeUrlEncodedData(password(), false) + "&sn=1";
154 net::NetworkTrafficAnnotationTag traffic_annotation =
155 net::DefineNetworkTrafficAnnotation("CRD_relay_session_request", R"(
156 semantics {
157 sender: "Chrome Remote Desktop"
158 description:
159 "Request is sent by Chrome Remote Desktop to allocate relay "
160 "session. Returned relay session credentials are used over UDP to "
161 "connect to Google-owned relay servers, which is required for NAT "
162 "traversal."
163 trigger:
164 "Start of each Chrome Remote Desktop and during connection when "
165 "peer-to-peer transport needs to be reconnected."
166 data:
167 "A temporary authentication token issued by Google services (over "
168 "XMPP connection)."
169 destination: GOOGLE_OWNED_SERVICE
170 }
171 policy {
172 cookies_allowed: false
173 setting:
174 "This feature cannot be disabled by settings. You can block Chrome "
175 "Remote Desktop as specified here: "
176 "https://support.google.com/chrome/?p=remote_desktop"
177 chrome_policy {
178 RemoteAccessHostFirewallTraversal {
179 policy_options {mode: MANDATORY}
180 RemoteAccessHostFirewallTraversal: false
181 }
182 }
183 policy_exception_justification:
184 "Above specified policy is only applicable on the host side and "
185 "doesn't have effect in Android and iOS client apps. The product "
186 "is shipped separately from Chromium, except on Chrome OS."
187 })");
153 std::unique_ptr<UrlRequest> url_request = 188 std::unique_ptr<UrlRequest> url_request =
154 transport_context_->url_request_factory()->CreateUrlRequest( 189 transport_context_->url_request_factory()->CreateUrlRequest(
155 UrlRequest::Type::GET, url); 190 UrlRequest::Type::GET, url, traffic_annotation);
156 url_request->AddHeader("X-Talk-Google-Relay-Auth: " + 191 url_request->AddHeader("X-Talk-Google-Relay-Auth: " +
157 ice_config_.relay_token); 192 ice_config_.relay_token);
158 url_request->AddHeader("X-Google-Relay-Auth: " + ice_config_.relay_token); 193 url_request->AddHeader("X-Google-Relay-Auth: " + ice_config_.relay_token);
159 url_request->AddHeader("X-Stream-Type: chromoting"); 194 url_request->AddHeader("X-Stream-Type: chromoting");
160 url_request->Start(base::Bind(&PortAllocatorSession::OnSessionRequestResult, 195 url_request->Start(base::Bind(&PortAllocatorSession::OnSessionRequestResult,
161 base::Unretained(this))); 196 base::Unretained(this)));
162 url_requests_.insert(std::move(url_request)); 197 url_requests_.insert(std::move(url_request));
163 } 198 }
164 199
165 void PortAllocatorSession::OnSessionRequestResult( 200 void PortAllocatorSession::OnSessionRequestResult(
(...skipping 27 matching lines...) Expand all
193 relay_config.ports.push_back( 228 relay_config.ports.push_back(
194 cricket::ProtocolAddress(address, cricket::PROTO_UDP)); 229 cricket::ProtocolAddress(address, cricket::PROTO_UDP));
195 config->AddRelay(relay_config); 230 config->AddRelay(relay_config);
196 } 231 }
197 232
198 ConfigReady(config.release()); 233 ConfigReady(config.release());
199 } 234 }
200 235
201 } // namespace protocol 236 } // namespace protocol
202 } // namespace remoting 237 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/http_ice_config_request_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698