OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ |
6 #define CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <memory> |
| 11 |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
12 #include "content/browser/loader/layered_resource_handler.h" | 14 #include "content/browser/loader/layered_resource_handler.h" |
13 #include "content/public/browser/resource_controller.h" | 15 #include "content/public/browser/resource_controller.h" |
14 #include "net/url_request/redirect_info.h" | 16 #include "net/url_request/redirect_info.h" |
15 #include "url/gurl.h" | 17 #include "url/gurl.h" |
16 | 18 |
17 namespace net { | 19 namespace net { |
18 class URLRequest; | 20 class URLRequest; |
19 } | 21 } |
20 | 22 |
21 namespace content { | 23 namespace content { |
22 | 24 |
23 class ResourceThrottle; | 25 class ResourceThrottle; |
24 struct ResourceResponse; | 26 struct ResourceResponse; |
25 | 27 |
26 // Used to apply a list of ResourceThrottle instances to an URLRequest. | 28 // Used to apply a list of ResourceThrottle instances to an URLRequest. |
27 class ThrottlingResourceHandler : public LayeredResourceHandler, | 29 class ThrottlingResourceHandler : public LayeredResourceHandler, |
28 public ResourceController { | 30 public ResourceController { |
29 public: | 31 public: |
30 // Takes ownership of the ResourceThrottle instances. | 32 // Takes ownership of the ResourceThrottle instances. |
31 ThrottlingResourceHandler(std::unique_ptr<ResourceHandler> next_handler, | 33 ThrottlingResourceHandler(std::unique_ptr<ResourceHandler> next_handler, |
32 net::URLRequest* request, | 34 net::URLRequest* request, |
33 ScopedVector<ResourceThrottle> throttles); | 35 ScopedVector<ResourceThrottle> throttles); |
34 ~ThrottlingResourceHandler() override; | 36 ~ThrottlingResourceHandler() override; |
35 | 37 |
36 // LayeredResourceHandler overrides: | 38 // LayeredResourceHandler overrides: |
37 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 39 void OnRequestRedirected( |
38 ResourceResponse* response, | 40 const net::RedirectInfo& redirect_info, |
39 bool* defer) override; | 41 ResourceResponse* response, |
40 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 42 std::unique_ptr<ResourceController> controller) override; |
41 bool OnWillStart(const GURL& url, bool* defer) override; | 43 void OnResponseStarted( |
| 44 ResourceResponse* response, |
| 45 std::unique_ptr<ResourceController> controller) override; |
| 46 void OnWillStart(const GURL& url, |
| 47 std::unique_ptr<ResourceController> controller) override; |
42 | 48 |
43 // ResourceController implementation: | 49 // ResourceController implementation: |
44 void Cancel() override; | 50 void Cancel() override; |
45 void CancelAndIgnore() override; | 51 void CancelAndIgnore() override; |
46 void CancelWithError(int error_code) override; | 52 void CancelWithError(int error_code) override; |
47 void Resume() override; | 53 void Resume() override; |
48 | 54 |
49 private: | 55 private: |
50 void ResumeStart(); | 56 void ResumeStart(); |
51 void ResumeRedirect(); | 57 void ResumeRedirect(); |
(...skipping 17 matching lines...) Expand all Loading... |
69 GURL deferred_url_; | 75 GURL deferred_url_; |
70 net::RedirectInfo deferred_redirect_; | 76 net::RedirectInfo deferred_redirect_; |
71 scoped_refptr<ResourceResponse> deferred_response_; | 77 scoped_refptr<ResourceResponse> deferred_response_; |
72 | 78 |
73 bool cancelled_by_resource_throttle_; | 79 bool cancelled_by_resource_throttle_; |
74 }; | 80 }; |
75 | 81 |
76 } // namespace content | 82 } // namespace content |
77 | 83 |
78 #endif // CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ | 84 #endif // CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ |
OLD | NEW |