OLD | NEW |
---|---|
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 "net/url_request/report_sender.h" | 5 #include "net/url_request/report_sender.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "net/base/elements_upload_data_stream.h" | 10 #include "net/base/elements_upload_data_stream.h" |
11 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
12 #include "net/base/request_priority.h" | 12 #include "net/base/request_priority.h" |
13 #include "net/base/upload_bytes_element_reader.h" | 13 #include "net/base/upload_bytes_element_reader.h" |
14 #include "net/traffic_annotation/network_traffic_annotation.h" | |
14 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
15 #include "net/url_request/url_request_status.h" | 16 #include "net/url_request/url_request_status.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 const void* const kUserDataKey = &kUserDataKey; | 19 const void* const kUserDataKey = &kUserDataKey; |
19 | 20 |
20 class CallbackInfo : public base::SupportsUserData::Data { | 21 class CallbackInfo : public base::SupportsUserData::Data { |
21 public: | 22 public: |
22 CallbackInfo(const net::ReportSender::SuccessCallback& success_callback, | 23 CallbackInfo(const net::ReportSender::SuccessCallback& success_callback, |
23 const net::ReportSender::ErrorCallback& error_callback) | 24 const net::ReportSender::ErrorCallback& error_callback) |
(...skipping 23 matching lines...) Expand all Loading... | |
47 | 48 |
48 ReportSender::~ReportSender() { | 49 ReportSender::~ReportSender() { |
49 } | 50 } |
50 | 51 |
51 void ReportSender::Send(const GURL& report_uri, | 52 void ReportSender::Send(const GURL& report_uri, |
52 base::StringPiece content_type, | 53 base::StringPiece content_type, |
53 base::StringPiece report, | 54 base::StringPiece report, |
54 const SuccessCallback& success_callback, | 55 const SuccessCallback& success_callback, |
55 const ErrorCallback& error_callback) { | 56 const ErrorCallback& error_callback) { |
56 DCHECK(!content_type.empty()); | 57 DCHECK(!content_type.empty()); |
57 std::unique_ptr<URLRequest> url_request = | 58 net::NetworkTrafficAnnotationTag traffic_annotation = |
58 request_context_->CreateRequest(report_uri, DEFAULT_PRIORITY, this); | 59 net::DefineNetworkTrafficAnnotation("...", R"( |
60 semantics { | |
61 sender: "..." | |
62 description: "..." | |
63 trigger: "..." | |
64 data: "..." | |
65 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER/LOCAL | |
66 } | |
67 policy { | |
68 cookies_allowed: false/true | |
69 cookies_store: "..." | |
70 setting: "..." | |
71 chrome_policy { | |
72 [POLICY_NAME] { | |
73 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
74 [POLICY_NAME]: ... //(value to disable it) | |
75 } | |
76 } | |
77 policy_exception_justification: "..." | |
78 })"); | |
79 std::unique_ptr<URLRequest> url_request = request_context_->CreateRequest( | |
80 report_uri, DEFAULT_PRIORITY, this, traffic_annotation); | |
meacer
2017/04/27 17:55:28
* sender: "Safe Browsing Extended Reporting"
Howe
Jialiu Lin
2017/04/27 18:04:53
I think the annotation should be added to each of
estark
2017/04/28 05:18:28
Yeah, I agree with Jialiu that it's infeasible to
| |
59 url_request->SetUserData( | 81 url_request->SetUserData( |
60 &kUserDataKey, | 82 &kUserDataKey, |
61 base::MakeUnique<CallbackInfo>(success_callback, error_callback)); | 83 base::MakeUnique<CallbackInfo>(success_callback, error_callback)); |
62 | 84 |
63 int load_flags = | 85 int load_flags = |
64 LOAD_BYPASS_CACHE | LOAD_DISABLE_CACHE | LOAD_DO_NOT_SEND_AUTH_DATA; | 86 LOAD_BYPASS_CACHE | LOAD_DISABLE_CACHE | LOAD_DO_NOT_SEND_AUTH_DATA; |
65 if (cookies_preference_ != SEND_COOKIES) { | 87 if (cookies_preference_ != SEND_COOKIES) { |
66 load_flags |= LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES; | 88 load_flags |= LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES; |
67 } | 89 } |
68 url_request->SetLoadFlags(load_flags); | 90 url_request->SetLoadFlags(load_flags); |
(...skipping 30 matching lines...) Expand all Loading... | |
99 } | 121 } |
100 | 122 |
101 CHECK_GT(inflight_requests_.erase(request), 0u); | 123 CHECK_GT(inflight_requests_.erase(request), 0u); |
102 } | 124 } |
103 | 125 |
104 void ReportSender::OnReadCompleted(URLRequest* request, int bytes_read) { | 126 void ReportSender::OnReadCompleted(URLRequest* request, int bytes_read) { |
105 NOTREACHED(); | 127 NOTREACHED(); |
106 } | 128 } |
107 | 129 |
108 } // namespace net | 130 } // namespace net |
OLD | NEW |