OLD | NEW |
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 #ifndef REMOTING_BASE_CHROMIUM_URL_REQUEST_H_ | 5 #ifndef REMOTING_BASE_CHROMIUM_URL_REQUEST_H_ |
6 #define REMOTING_BASE_CHROMIUM_URL_REQUEST_H_ | 6 #define REMOTING_BASE_CHROMIUM_URL_REQUEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "net/traffic_annotation/network_traffic_annotation.h" |
12 #include "net/url_request/url_fetcher_delegate.h" | 13 #include "net/url_request/url_fetcher_delegate.h" |
13 #include "remoting/base/url_request.h" | 14 #include "remoting/base/url_request.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 class URLRequestContextGetter; | 17 class URLRequestContextGetter; |
17 } // namespace net | 18 } // namespace net |
18 | 19 |
19 namespace remoting { | 20 namespace remoting { |
20 | 21 |
21 // UrlRequest implementation based on net::URLFetcher. | 22 // UrlRequest implementation based on net::URLFetcher. |
22 class ChromiumUrlRequest : public UrlRequest, public net::URLFetcherDelegate { | 23 class ChromiumUrlRequest : public UrlRequest, public net::URLFetcherDelegate { |
23 public: | 24 public: |
24 ChromiumUrlRequest(scoped_refptr<net::URLRequestContextGetter> url_context, | 25 ChromiumUrlRequest( |
25 UrlRequest::Type type, | 26 scoped_refptr<net::URLRequestContextGetter> url_context, |
26 const std::string& url); | 27 UrlRequest::Type type, |
| 28 const std::string& url, |
| 29 const net::NetworkTrafficAnnotationTag& traffic_annotation); |
27 ~ChromiumUrlRequest() override; | 30 ~ChromiumUrlRequest() override; |
28 | 31 |
29 // UrlRequest interface. | 32 // UrlRequest interface. |
30 void AddHeader(const std::string& value) override; | 33 void AddHeader(const std::string& value) override; |
31 void SetPostData(const std::string& content_type, | 34 void SetPostData(const std::string& content_type, |
32 const std::string& data) override; | 35 const std::string& data) override; |
33 void Start(const OnResultCallback& on_result_callback) override; | 36 void Start(const OnResultCallback& on_result_callback) override; |
34 | 37 |
35 private: | 38 private: |
36 // net::URLFetcherDelegate interface. | 39 // net::URLFetcherDelegate interface. |
37 void OnURLFetchComplete(const net::URLFetcher* url_fetcher) override; | 40 void OnURLFetchComplete(const net::URLFetcher* url_fetcher) override; |
38 | 41 |
39 std::unique_ptr<net::URLFetcher> url_fetcher_; | 42 std::unique_ptr<net::URLFetcher> url_fetcher_; |
40 OnResultCallback on_result_callback_; | 43 OnResultCallback on_result_callback_; |
41 }; | 44 }; |
42 | 45 |
43 class ChromiumUrlRequestFactory : public UrlRequestFactory { | 46 class ChromiumUrlRequestFactory : public UrlRequestFactory { |
44 public: | 47 public: |
45 ChromiumUrlRequestFactory( | 48 ChromiumUrlRequestFactory( |
46 scoped_refptr<net::URLRequestContextGetter> url_context); | 49 scoped_refptr<net::URLRequestContextGetter> url_context); |
47 ~ChromiumUrlRequestFactory() override; | 50 ~ChromiumUrlRequestFactory() override; |
48 | 51 |
49 // UrlRequestFactory interface. | 52 // UrlRequestFactory interface. |
50 std::unique_ptr<UrlRequest> CreateUrlRequest(UrlRequest::Type type, | 53 std::unique_ptr<UrlRequest> CreateUrlRequest( |
51 const std::string& url) override; | 54 UrlRequest::Type type, |
| 55 const std::string& url, |
| 56 const net::NetworkTrafficAnnotationTag& traffic_annotation) override; |
52 | 57 |
53 private: | 58 private: |
54 scoped_refptr<net::URLRequestContextGetter> url_context_; | 59 scoped_refptr<net::URLRequestContextGetter> url_context_; |
55 }; | 60 }; |
56 | 61 |
57 } // namespace remoting | 62 } // namespace remoting |
58 | 63 |
59 #endif // REMOTING_BASE_CHROMIUM_URL_REQUEST_H_ | 64 #endif // REMOTING_BASE_CHROMIUM_URL_REQUEST_H_ |
OLD | NEW |