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

Side by Side Diff: remoting/host/gcd_rest_client.cc

Issue 2737463002: Network traffic annotation added to remoting/host. (Closed)
Patch Set: Created 3 years, 9 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/host/dns_blackhole_checker.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/host/gcd_rest_client.h" 5 #include "remoting/host/gcd_rest_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/time/default_clock.h" 16 #include "base/time/default_clock.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "net/traffic_annotation/network_traffic_annotation.h"
18 #include "net/url_request/url_fetcher.h" 19 #include "net/url_request/url_fetcher.h"
19 #include "remoting/base/logging.h" 20 #include "remoting/base/logging.h"
20 21
21 namespace remoting { 22 namespace remoting {
22 23
23 GcdRestClient::GcdRestClient(const std::string& gcd_base_url, 24 GcdRestClient::GcdRestClient(const std::string& gcd_base_url,
24 const std::string& gcd_device_id, 25 const std::string& gcd_device_id,
25 const scoped_refptr<net::URLRequestContextGetter>& 26 const scoped_refptr<net::URLRequestContextGetter>&
26 url_request_context_getter, 27 url_request_context_getter,
27 OAuthTokenGetter* token_getter) 28 OAuthTokenGetter* token_getter)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 callback.Run(OTHER_ERROR); 71 callback.Run(OTHER_ERROR);
71 return; 72 return;
72 } 73 }
73 DLOG(INFO) << "sending state patch: " << patch_string; 74 DLOG(INFO) << "sending state patch: " << patch_string;
74 75
75 std::string url = 76 std::string url =
76 gcd_base_url_ + "/devices/" + gcd_device_id_ + "/patchState"; 77 gcd_base_url_ + "/devices/" + gcd_device_id_ + "/patchState";
77 78
78 // Prepare an HTTP request to issue once an auth token is available. 79 // Prepare an HTTP request to issue once an auth token is available.
79 callback_ = callback; 80 callback_ = callback;
80 url_fetcher_ = 81 net::NetworkTrafficAnnotationTag traffic_annotation =
81 net::URLFetcher::Create(GURL(url), net::URLFetcher::POST, this); 82 net::DefineNetworkTrafficAnnotation("...", R"(
83 semantics {
84 sender: "..."
85 description: "..."
86 trigger: "..."
87 data: "..."
88 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
89 }
90 policy {
91 cookies_allowed: false/true
92 cookies_store: "..."
93 setting: "..."
94 policy {
95 [POLICY_NAME] {
96 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
97 [POLICY_NAME]: ... //(value to disable it)
98 }
99 }
100 policy_exception_justification: "..."
101 })");
102 url_fetcher_ = net::URLFetcher::Create(GURL(url), net::URLFetcher::POST, this,
103 traffic_annotation);
82 url_fetcher_->SetUploadData("application/json", patch_string); 104 url_fetcher_->SetUploadData("application/json", patch_string);
83 if (url_request_context_getter_) { 105 if (url_request_context_getter_) {
84 url_fetcher_->SetRequestContext(url_request_context_getter_.get()); 106 url_fetcher_->SetRequestContext(url_request_context_getter_.get());
85 } 107 }
86 108
87 token_getter_->CallWithToken( 109 token_getter_->CallWithToken(
88 base::Bind(&GcdRestClient::OnTokenReceived, base::Unretained(this))); 110 base::Bind(&GcdRestClient::OnTokenReceived, base::Unretained(this)));
89 } 111 }
90 112
91 void GcdRestClient::SetClockForTest(std::unique_ptr<base::Clock> clock) { 113 void GcdRestClient::SetClockForTest(std::unique_ptr<base::Clock> clock) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 << ") fetching URL: " << request_url; 159 << ") fetching URL: " << request_url;
138 status = NETWORK_ERROR; 160 status = NETWORK_ERROR;
139 } else { 161 } else {
140 LOG(ERROR) << "Error (" << response << ") fetching URL: " << request_url; 162 LOG(ERROR) << "Error (" << response << ") fetching URL: " << request_url;
141 } 163 }
142 164
143 FinishCurrentRequest(status); 165 FinishCurrentRequest(status);
144 } 166 }
145 167
146 } // namespace remoting 168 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/dns_blackhole_checker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698