| 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_RENDERER_HOST_THROTTLING_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_THROTTLING_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_THROTTLING_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_THROTTLING_RESOURCE_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "content/browser/renderer_host/layered_resource_handler.h" | 11 #include "content/browser/renderer_host/layered_resource_handler.h" |
| 12 #include "content/public/browser/resource_throttle_controller.h" | 12 #include "content/public/browser/resource_controller.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 class ResourceDispatcherHostImpl; | |
| 18 class ResourceThrottle; | 17 class ResourceThrottle; |
| 19 struct ResourceResponse; | 18 struct ResourceResponse; |
| 20 | 19 |
| 21 // Used to apply a list of ResourceThrottle instances to an URLRequest. | 20 // Used to apply a list of ResourceThrottle instances to an URLRequest. |
| 22 class ThrottlingResourceHandler : public LayeredResourceHandler, | 21 class ThrottlingResourceHandler : public LayeredResourceHandler, |
| 23 public ResourceThrottleController { | 22 public ResourceController { |
| 24 public: | 23 public: |
| 25 // Takes ownership of the ResourceThrottle instances. | 24 // Takes ownership of the ResourceThrottle instances. |
| 26 ThrottlingResourceHandler(ResourceDispatcherHostImpl* host, | 25 ThrottlingResourceHandler(scoped_ptr<ResourceHandler> next_handler, |
| 27 scoped_ptr<ResourceHandler> next_handler, | |
| 28 int child_id, | 26 int child_id, |
| 29 int request_id, | 27 int request_id, |
| 30 ScopedVector<ResourceThrottle> throttles); | 28 ScopedVector<ResourceThrottle> throttles); |
| 31 virtual ~ThrottlingResourceHandler(); | 29 virtual ~ThrottlingResourceHandler(); |
| 32 | 30 |
| 33 // LayeredResourceHandler overrides: | 31 // LayeredResourceHandler overrides: |
| 34 virtual bool OnRequestRedirected(int request_id, const GURL& url, | 32 virtual bool OnRequestRedirected(int request_id, const GURL& url, |
| 35 ResourceResponse* response, | 33 ResourceResponse* response, |
| 36 bool* defer) OVERRIDE; | 34 bool* defer) OVERRIDE; |
| 37 virtual bool OnResponseStarted(int request_id, | 35 virtual bool OnResponseStarted(int request_id, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 50 void ResumeResponse(); | 48 void ResumeResponse(); |
| 51 | 49 |
| 52 enum DeferredStage { | 50 enum DeferredStage { |
| 53 DEFERRED_NONE, | 51 DEFERRED_NONE, |
| 54 DEFERRED_START, | 52 DEFERRED_START, |
| 55 DEFERRED_REDIRECT, | 53 DEFERRED_REDIRECT, |
| 56 DEFERRED_RESPONSE | 54 DEFERRED_RESPONSE |
| 57 }; | 55 }; |
| 58 DeferredStage deferred_stage_; | 56 DeferredStage deferred_stage_; |
| 59 | 57 |
| 60 ResourceDispatcherHostImpl* host_; | |
| 61 int child_id_; | 58 int child_id_; |
| 62 int request_id_; | 59 int request_id_; |
| 63 | 60 |
| 64 ScopedVector<ResourceThrottle> throttles_; | 61 ScopedVector<ResourceThrottle> throttles_; |
| 65 size_t index_; | 62 size_t index_; |
| 66 | 63 |
| 67 GURL deferred_url_; | 64 GURL deferred_url_; |
| 68 scoped_refptr<ResourceResponse> deferred_response_; | 65 scoped_refptr<ResourceResponse> deferred_response_; |
| 69 }; | 66 }; |
| 70 | 67 |
| 71 } // namespace content | 68 } // namespace content |
| 72 | 69 |
| 73 #endif // CONTENT_BROWSER_RENDERER_HOST_THROTTLING_RESOURCE_HANDLER_H_ | 70 #endif // CONTENT_BROWSER_RENDERER_HOST_THROTTLING_RESOURCE_HANDLER_H_ |
| OLD | NEW |