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 HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ | 5 #ifndef HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ |
6 #define HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ | 6 #define HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <functional> | 9 #include <functional> |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "headless/public/headless_export.h" |
16 #include "headless/public/util/managed_dispatch_url_request_job.h" | 17 #include "headless/public/util/managed_dispatch_url_request_job.h" |
17 #include "headless/public/util/url_fetcher.h" | 18 #include "headless/public/util/url_fetcher.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 class HttpResponseHeaders; | 24 class HttpResponseHeaders; |
24 class IOBuffer; | 25 class IOBuffer; |
25 } // namespace net | 26 } // namespace net |
26 | 27 |
27 namespace headless { | 28 namespace headless { |
28 | 29 |
29 class URLRequestDispatcher; | 30 class URLRequestDispatcher; |
30 | 31 |
31 // Intended for use in a protocol handler, this ManagedDispatchURLRequestJob has | 32 // Intended for use in a protocol handler, this ManagedDispatchURLRequestJob has |
32 // the following features: | 33 // the following features: |
33 // | 34 // |
34 // 1. The delegate can extension observe / cancel and redirect requests | 35 // 1. The delegate can extension observe / cancel and redirect requests |
35 // 2. The delegate can optionally provide the results, otherwise the specifed | 36 // 2. The delegate can optionally provide the results, otherwise the specifed |
36 // fetcher is invoked. | 37 // fetcher is invoked. |
37 class GenericURLRequestJob : public ManagedDispatchURLRequestJob, | 38 class HEADLESS_EXPORT GenericURLRequestJob |
38 public URLFetcher::ResultListener { | 39 : public ManagedDispatchURLRequestJob, |
| 40 public URLFetcher::ResultListener { |
39 public: | 41 public: |
40 enum class RewriteResult { kAllow, kDeny, kFailure }; | 42 enum class RewriteResult { kAllow, kDeny, kFailure }; |
41 using RewriteCallback = std::function< | 43 using RewriteCallback = std::function< |
42 void(RewriteResult result, const GURL& url, const std::string& method)>; | 44 void(RewriteResult result, const GURL& url, const std::string& method)>; |
43 | 45 |
44 struct HttpResponse { | 46 struct HttpResponse { |
45 GURL final_url; | 47 GURL final_url; |
46 int http_response_code; | 48 int http_response_code; |
47 | 49 |
48 // The HTTP headers and response body. Note the lifetime of |response_data| | 50 // The HTTP headers and response body. Note the lifetime of |response_data| |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 base::TimeTicks response_time_; | 131 base::TimeTicks response_time_; |
130 | 132 |
131 base::WeakPtrFactory<GenericURLRequestJob> weak_factory_; | 133 base::WeakPtrFactory<GenericURLRequestJob> weak_factory_; |
132 | 134 |
133 DISALLOW_COPY_AND_ASSIGN(GenericURLRequestJob); | 135 DISALLOW_COPY_AND_ASSIGN(GenericURLRequestJob); |
134 }; | 136 }; |
135 | 137 |
136 } // namespace headless | 138 } // namespace headless |
137 | 139 |
138 #endif // HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ | 140 #endif // HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ |
OLD | NEW |