| 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_ASYNC_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "content/browser/loader/resource_handler.h" | 11 #include "content/browser/loader/resource_handler.h" |
| 12 #include "content/browser/loader/resource_message_delegate.h" | 12 #include "content/browser/loader/resource_message_delegate.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 class URLRequest; | 16 class URLRequest; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class ResourceBuffer; | 20 class ResourceBuffer; |
| 21 class ResourceContext; |
| 21 class ResourceDispatcherHostImpl; | 22 class ResourceDispatcherHostImpl; |
| 22 class ResourceMessageFilter; | 23 class ResourceMessageFilter; |
| 23 class SharedIOBuffer; | 24 class SharedIOBuffer; |
| 24 | 25 |
| 25 // Used to complete an asynchronous resource request in response to resource | 26 // Used to complete an asynchronous resource request in response to resource |
| 26 // load events from the resource dispatcher host. | 27 // load events from the resource dispatcher host. |
| 27 class AsyncResourceHandler : public ResourceHandler, | 28 class AsyncResourceHandler : public ResourceHandler, |
| 28 public ResourceMessageDelegate { | 29 public ResourceMessageDelegate { |
| 29 public: | 30 public: |
| 30 AsyncResourceHandler(ResourceMessageFilter* filter, | 31 AsyncResourceHandler(ResourceMessageFilter* filter, |
| 32 ResourceContext* resource_context, |
| 31 net::URLRequest* request, | 33 net::URLRequest* request, |
| 32 ResourceDispatcherHostImpl* rdh); | 34 ResourceDispatcherHostImpl* rdh); |
| 33 virtual ~AsyncResourceHandler(); | 35 virtual ~AsyncResourceHandler(); |
| 34 | 36 |
| 35 virtual bool OnMessageReceived(const IPC::Message& message, | 37 virtual bool OnMessageReceived(const IPC::Message& message, |
| 36 bool* message_was_ok) OVERRIDE; | 38 bool* message_was_ok) OVERRIDE; |
| 37 | 39 |
| 38 // ResourceHandler implementation: | 40 // ResourceHandler implementation: |
| 39 virtual bool OnUploadProgress(int request_id, | 41 virtual bool OnUploadProgress(int request_id, |
| 40 uint64 position, | 42 uint64 position, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 67 void OnFollowRedirect(int request_id, | 69 void OnFollowRedirect(int request_id, |
| 68 bool has_new_first_party_for_cookies, | 70 bool has_new_first_party_for_cookies, |
| 69 const GURL& new_first_party_for_cookies); | 71 const GURL& new_first_party_for_cookies); |
| 70 void OnDataReceivedACK(int request_id); | 72 void OnDataReceivedACK(int request_id); |
| 71 | 73 |
| 72 bool EnsureResourceBufferIsInitialized(); | 74 bool EnsureResourceBufferIsInitialized(); |
| 73 void ResumeIfDeferred(); | 75 void ResumeIfDeferred(); |
| 74 | 76 |
| 75 scoped_refptr<ResourceBuffer> buffer_; | 77 scoped_refptr<ResourceBuffer> buffer_; |
| 76 scoped_refptr<ResourceMessageFilter> filter_; | 78 scoped_refptr<ResourceMessageFilter> filter_; |
| 79 ResourceContext* resource_context_; |
| 77 net::URLRequest* request_; | 80 net::URLRequest* request_; |
| 78 ResourceDispatcherHostImpl* rdh_; | 81 ResourceDispatcherHostImpl* rdh_; |
| 79 | 82 |
| 80 // Number of messages we've sent to the renderer that we haven't gotten an | 83 // Number of messages we've sent to the renderer that we haven't gotten an |
| 81 // ACK for. This allows us to avoid having too many messages in flight. | 84 // ACK for. This allows us to avoid having too many messages in flight. |
| 82 int pending_data_count_; | 85 int pending_data_count_; |
| 83 | 86 |
| 84 int allocation_size_; | 87 int allocation_size_; |
| 85 | 88 |
| 86 bool did_defer_; | 89 bool did_defer_; |
| 87 | 90 |
| 88 bool has_checked_for_sufficient_resources_; | 91 bool has_checked_for_sufficient_resources_; |
| 89 bool sent_received_response_msg_; | 92 bool sent_received_response_msg_; |
| 90 bool sent_first_data_msg_; | 93 bool sent_first_data_msg_; |
| 91 | 94 |
| 92 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); | 95 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); |
| 93 }; | 96 }; |
| 94 | 97 |
| 95 } // namespace content | 98 } // namespace content |
| 96 | 99 |
| 97 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ | 100 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_ |
| OLD | NEW |