| 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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "content/browser/loader/layered_resource_handler.h" | 10 #include "content/browser/loader/layered_resource_handler.h" |
| 11 #include "content/public/browser/resource_controller.h" | 11 #include "content/public/browser/resource_controller.h" |
| 12 #include "net/url_request/redirect_info.h" |
| 12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 class URLRequest; | 16 class URLRequest; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 class ResourceThrottle; | 21 class ResourceThrottle; |
| 21 struct ResourceResponse; | 22 struct ResourceResponse; |
| 22 | 23 |
| 23 // Used to apply a list of ResourceThrottle instances to an URLRequest. | 24 // Used to apply a list of ResourceThrottle instances to an URLRequest. |
| 24 class ThrottlingResourceHandler : public LayeredResourceHandler, | 25 class ThrottlingResourceHandler : public LayeredResourceHandler, |
| 25 public ResourceController { | 26 public ResourceController { |
| 26 public: | 27 public: |
| 27 // Takes ownership of the ResourceThrottle instances. | 28 // Takes ownership of the ResourceThrottle instances. |
| 28 ThrottlingResourceHandler(scoped_ptr<ResourceHandler> next_handler, | 29 ThrottlingResourceHandler(scoped_ptr<ResourceHandler> next_handler, |
| 29 net::URLRequest* request, | 30 net::URLRequest* request, |
| 30 ScopedVector<ResourceThrottle> throttles); | 31 ScopedVector<ResourceThrottle> throttles); |
| 31 virtual ~ThrottlingResourceHandler(); | 32 virtual ~ThrottlingResourceHandler(); |
| 32 | 33 |
| 33 // LayeredResourceHandler overrides: | 34 // LayeredResourceHandler overrides: |
| 34 virtual bool OnRequestRedirected(const GURL& url, | 35 virtual bool OnRequestRedirected(const net::RedirectInfo& redirect_info, |
| 35 ResourceResponse* response, | 36 ResourceResponse* response, |
| 36 bool* defer) OVERRIDE; | 37 bool* defer) OVERRIDE; |
| 37 virtual bool OnResponseStarted(ResourceResponse* response, | 38 virtual bool OnResponseStarted(ResourceResponse* response, |
| 38 bool* defer) OVERRIDE; | 39 bool* defer) OVERRIDE; |
| 39 virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; | 40 virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; |
| 40 virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; | 41 virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; |
| 41 | 42 |
| 42 // ResourceController implementation: | 43 // ResourceController implementation: |
| 43 virtual void Cancel() OVERRIDE; | 44 virtual void Cancel() OVERRIDE; |
| 44 virtual void CancelAndIgnore() OVERRIDE; | 45 virtual void CancelAndIgnore() OVERRIDE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 61 DEFERRED_NETWORK_START, | 62 DEFERRED_NETWORK_START, |
| 62 DEFERRED_REDIRECT, | 63 DEFERRED_REDIRECT, |
| 63 DEFERRED_RESPONSE | 64 DEFERRED_RESPONSE |
| 64 }; | 65 }; |
| 65 DeferredStage deferred_stage_; | 66 DeferredStage deferred_stage_; |
| 66 | 67 |
| 67 ScopedVector<ResourceThrottle> throttles_; | 68 ScopedVector<ResourceThrottle> throttles_; |
| 68 size_t next_index_; | 69 size_t next_index_; |
| 69 | 70 |
| 70 GURL deferred_url_; | 71 GURL deferred_url_; |
| 72 net::RedirectInfo deferred_redirect_; |
| 71 scoped_refptr<ResourceResponse> deferred_response_; | 73 scoped_refptr<ResourceResponse> deferred_response_; |
| 72 | 74 |
| 73 bool cancelled_by_resource_throttle_; | 75 bool cancelled_by_resource_throttle_; |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 } // namespace content | 78 } // namespace content |
| 77 | 79 |
| 78 #endif // CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ | 80 #endif // CONTENT_BROWSER_LOADER_THROTTLING_RESOURCE_HANDLER_H_ |
| OLD | NEW |