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 "net/base/elements_upload_data_stream.h" | 10 #include "net/base/elements_upload_data_stream.h" |
10 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
11 #include "net/base/request_priority.h" | 12 #include "net/base/request_priority.h" |
12 #include "net/base/upload_bytes_element_reader.h" | 13 #include "net/base/upload_bytes_element_reader.h" |
13 #include "net/url_request/url_request_context.h" | 14 #include "net/url_request/url_request_context.h" |
14 #include "net/url_request/url_request_status.h" | 15 #include "net/url_request/url_request_status.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 const void* const kUserDataKey = &kUserDataKey; | 18 const void* const kUserDataKey = &kUserDataKey; |
18 | 19 |
(...skipping 29 matching lines...) Expand all Loading... |
48 } | 49 } |
49 | 50 |
50 void ReportSender::Send(const GURL& report_uri, | 51 void ReportSender::Send(const GURL& report_uri, |
51 base::StringPiece content_type, | 52 base::StringPiece content_type, |
52 base::StringPiece report, | 53 base::StringPiece report, |
53 const SuccessCallback& success_callback, | 54 const SuccessCallback& success_callback, |
54 const ErrorCallback& error_callback) { | 55 const ErrorCallback& error_callback) { |
55 DCHECK(!content_type.empty()); | 56 DCHECK(!content_type.empty()); |
56 std::unique_ptr<URLRequest> url_request = | 57 std::unique_ptr<URLRequest> url_request = |
57 request_context_->CreateRequest(report_uri, DEFAULT_PRIORITY, this); | 58 request_context_->CreateRequest(report_uri, DEFAULT_PRIORITY, this); |
58 url_request->SetUserData(&kUserDataKey, | 59 url_request->SetUserData( |
59 new CallbackInfo(success_callback, error_callback)); | 60 &kUserDataKey, |
| 61 base::MakeUnique<CallbackInfo>(success_callback, error_callback)); |
60 | 62 |
61 int load_flags = | 63 int load_flags = |
62 LOAD_BYPASS_CACHE | LOAD_DISABLE_CACHE | LOAD_DO_NOT_SEND_AUTH_DATA; | 64 LOAD_BYPASS_CACHE | LOAD_DISABLE_CACHE | LOAD_DO_NOT_SEND_AUTH_DATA; |
63 if (cookies_preference_ != SEND_COOKIES) { | 65 if (cookies_preference_ != SEND_COOKIES) { |
64 load_flags |= LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES; | 66 load_flags |= LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES; |
65 } | 67 } |
66 url_request->SetLoadFlags(load_flags); | 68 url_request->SetLoadFlags(load_flags); |
67 | 69 |
68 HttpRequestHeaders extra_headers; | 70 HttpRequestHeaders extra_headers; |
69 extra_headers.SetHeader(HttpRequestHeaders::kContentType, content_type); | 71 extra_headers.SetHeader(HttpRequestHeaders::kContentType, content_type); |
(...skipping 27 matching lines...) Expand all Loading... |
97 } | 99 } |
98 | 100 |
99 CHECK_GT(inflight_requests_.erase(request), 0u); | 101 CHECK_GT(inflight_requests_.erase(request), 0u); |
100 } | 102 } |
101 | 103 |
102 void ReportSender::OnReadCompleted(URLRequest* request, int bytes_read) { | 104 void ReportSender::OnReadCompleted(URLRequest* request, int bytes_read) { |
103 NOTREACHED(); | 105 NOTREACHED(); |
104 } | 106 } |
105 | 107 |
106 } // namespace net | 108 } // namespace net |
OLD | NEW |