| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "content/browser/renderer_host/resource_handler.h" | |
| 11 #include "googleurl/src/gurl.h" | |
| 12 | |
| 13 namespace net { | |
| 14 class URLRequest; | |
| 15 } | |
| 16 | |
| 17 namespace content { | |
| 18 class ResourceBuffer; | |
| 19 class ResourceDispatcherHostImpl; | |
| 20 class ResourceMessageFilter; | |
| 21 class SharedIOBuffer; | |
| 22 | |
| 23 // Used to complete an asynchronous resource request in response to resource | |
| 24 // load events from the resource dispatcher host. | |
| 25 class AsyncResourceHandler : public ResourceHandler { | |
| 26 public: | |
| 27 AsyncResourceHandler(ResourceMessageFilter* filter, | |
| 28 int routing_id, | |
| 29 net::URLRequest* request, | |
| 30 ResourceDispatcherHostImpl* rdh); | |
| 31 virtual ~AsyncResourceHandler(); | |
| 32 | |
| 33 // IPC message handlers: | |
| 34 void OnFollowRedirect(bool has_new_first_party_for_cookies, | |
| 35 const GURL& new_first_party_for_cookies); | |
| 36 void OnDataReceivedACK(); | |
| 37 | |
| 38 // ResourceHandler implementation: | |
| 39 virtual bool OnUploadProgress(int request_id, | |
| 40 uint64 position, | |
| 41 uint64 size) OVERRIDE; | |
| 42 virtual bool OnRequestRedirected(int request_id, | |
| 43 const GURL& new_url, | |
| 44 ResourceResponse* response, | |
| 45 bool* defer) OVERRIDE; | |
| 46 virtual bool OnResponseStarted(int request_id, | |
| 47 ResourceResponse* response, | |
| 48 bool* defer) OVERRIDE; | |
| 49 virtual bool OnWillStart(int request_id, | |
| 50 const GURL& url, | |
| 51 bool* defer) OVERRIDE; | |
| 52 virtual bool OnWillRead(int request_id, | |
| 53 net::IOBuffer** buf, | |
| 54 int* buf_size, | |
| 55 int min_size) OVERRIDE; | |
| 56 virtual bool OnReadCompleted(int request_id, | |
| 57 int bytes_read, | |
| 58 bool* defer) OVERRIDE; | |
| 59 virtual bool OnResponseCompleted(int request_id, | |
| 60 const net::URLRequestStatus& status, | |
| 61 const std::string& security_info) OVERRIDE; | |
| 62 virtual void OnDataDownloaded(int request_id, | |
| 63 int bytes_downloaded) OVERRIDE; | |
| 64 | |
| 65 private: | |
| 66 bool EnsureResourceBufferIsInitialized(); | |
| 67 void ResumeIfDeferred(); | |
| 68 | |
| 69 scoped_refptr<ResourceBuffer> buffer_; | |
| 70 scoped_refptr<ResourceMessageFilter> filter_; | |
| 71 int routing_id_; | |
| 72 net::URLRequest* request_; | |
| 73 ResourceDispatcherHostImpl* rdh_; | |
| 74 | |
| 75 // Number of messages we've sent to the renderer that we haven't gotten an | |
| 76 // ACK for. This allows us to avoid having too many messages in flight. | |
| 77 int pending_data_count_; | |
| 78 | |
| 79 int allocation_size_; | |
| 80 | |
| 81 bool did_defer_; | |
| 82 | |
| 83 bool sent_received_response_msg_; | |
| 84 bool sent_first_data_msg_; | |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); | |
| 87 }; | |
| 88 | |
| 89 } // namespace content | |
| 90 | |
| 91 #endif // CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ | |
| OLD | NEW |