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

Side by Side Diff: chrome/browser/extensions/api/dial/device_description_fetcher.cc

Issue 2738243003: Network traffic annotation added to device_description_fetcher. (Closed)
Patch Set: Annotation updated. 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 | « no previous file | 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 (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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 "chrome/browser/extensions/api/dial/device_description_fetcher.h" 5 #include "chrome/browser/extensions/api/dial/device_description_fetcher.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/extensions/api/dial/dial_device_data.h" 9 #include "chrome/browser/extensions/api/dial/dial_device_data.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "net/base/load_flags.h" 12 #include "net/base/load_flags.h"
13 #include "net/http/http_response_headers.h" 13 #include "net/http/http_response_headers.h"
14 #include "net/http/http_status_code.h" 14 #include "net/http/http_status_code.h"
15 #include "net/http/http_util.h" 15 #include "net/http/http_util.h"
16 #include "net/traffic_annotation/network_traffic_annotation.h"
16 #include "net/url_request/url_fetcher.h" 17 #include "net/url_request/url_fetcher.h"
17 #include "net/url_request/url_request_context_getter.h" 18 #include "net/url_request/url_request_context_getter.h"
18 19
19 using content::BrowserThread; 20 using content::BrowserThread;
20 21
21 constexpr char kApplicationUrlHeaderName[] = "Application-URL"; 22 constexpr char kApplicationUrlHeaderName[] = "Application-URL";
22 constexpr int kMaxRetries = 3; 23 constexpr int kMaxRetries = 3;
23 // DIAL devices are unlikely to expose uPnP functions other than DIAL, so 256kb 24 // DIAL devices are unlikely to expose uPnP functions other than DIAL, so 256kb
24 // should be more than sufficient. 25 // should be more than sufficient.
25 constexpr int kMaxDescriptionSizeBytes = 262144; 26 constexpr int kMaxDescriptionSizeBytes = 262144;
(...skipping 16 matching lines...) Expand all
42 } 43 }
43 44
44 DeviceDescriptionFetcher::~DeviceDescriptionFetcher() { 45 DeviceDescriptionFetcher::~DeviceDescriptionFetcher() {
45 DCHECK(thread_checker_.CalledOnValidThread()); 46 DCHECK(thread_checker_.CalledOnValidThread());
46 } 47 }
47 48
48 void DeviceDescriptionFetcher::Start() { 49 void DeviceDescriptionFetcher::Start() {
49 DCHECK(thread_checker_.CalledOnValidThread()); 50 DCHECK(thread_checker_.CalledOnValidThread());
50 DCHECK(!fetcher_); 51 DCHECK(!fetcher_);
51 52
53 net::NetworkTrafficAnnotationTag traffic_annotation =
54 net::DefineNetworkTrafficAnnotation("dial_get_device_description", R"(
55 semantics {
56 sender: "DIAL"
57 description:
58 "Chromium sends a request to a device (such as a smart TV) "
59 "discovered via the DIAL (Disovery and Launch) protocol to obtain "
60 "its device description. Chromium then uses the device description "
61 "to determine the capabilities of the device to be used as a "
62 "target for casting media content."
63 trigger:
64 "A new or updated device has been discovered via DIAL in the local "
65 "network."
66 data: "An HTTP GET request."
67 destination: OTHER
68 destination_other:
69 "A device in the local network."
70 }
71 policy {
72 cookies_allowed: false
73 setting:
74 "This feature cannot be disabled by settings and can only be "
75 "disabled by media-router flag."
76 chrome_policy {
77 EnableMediaRouter {
78 policy_options {mode: MANDATORY}
79 EnableMediaRouter: false
80 }
81 }
82 })");
52 // DIAL returns device descriptions via GET request. 83 // DIAL returns device descriptions via GET request.
53 fetcher_ = 84 fetcher_ =
54 net::URLFetcher::Create(kURLFetcherIDForTest, device_description_url_, 85 net::URLFetcher::Create(kURLFetcherIDForTest, device_description_url_,
55 net::URLFetcher::GET, this); 86 net::URLFetcher::GET, this, traffic_annotation);
56 87
57 // net::LOAD_BYPASS_PROXY: Proxies almost certainly hurt more cases than they 88 // net::LOAD_BYPASS_PROXY: Proxies almost certainly hurt more cases than they
58 // help. 89 // help.
59 // net::LOAD_DISABLE_CACHE: The request should not touch the cache. 90 // net::LOAD_DISABLE_CACHE: The request should not touch the cache.
60 // net::LOAD_DO_NOT_{SAVE,SEND}_COOKIES: The request should not touch cookies. 91 // net::LOAD_DO_NOT_{SAVE,SEND}_COOKIES: The request should not touch cookies.
61 // net::LOAD_DO_NOT_SEND_AUTH_DATA: The request should not send auth data. 92 // net::LOAD_DO_NOT_SEND_AUTH_DATA: The request should not send auth data.
62 fetcher_->SetLoadFlags(net::LOAD_BYPASS_PROXY | net::LOAD_DISABLE_CACHE | 93 fetcher_->SetLoadFlags(net::LOAD_BYPASS_PROXY | net::LOAD_DISABLE_CACHE |
63 net::LOAD_DO_NOT_SAVE_COOKIES | 94 net::LOAD_DO_NOT_SAVE_COOKIES |
64 net::LOAD_DO_NOT_SEND_COOKIES | 95 net::LOAD_DO_NOT_SEND_COOKIES |
65 net::LOAD_DO_NOT_SEND_AUTH_DATA); 96 net::LOAD_DO_NOT_SEND_AUTH_DATA);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 int64_t current, 173 int64_t current,
143 int64_t total) {} 174 int64_t total) {}
144 175
145 void DeviceDescriptionFetcher::ReportError(const std::string& message) { 176 void DeviceDescriptionFetcher::ReportError(const std::string& message) {
146 std::move(error_cb_).Run(message); 177 std::move(error_cb_).Run(message);
147 } 178 }
148 179
149 } // namespace dial 180 } // namespace dial
150 } // namespace api 181 } // namespace api
151 } // namespace extensions 182 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698