OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ |
7 | 7 |
8 #include "base/process.h" | 8 #include "base/process.h" |
9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
10 #include "chrome/browser/renderer_host/resource_handler.h" | 10 #include "chrome/browser/renderer_host/resource_handler.h" |
11 | 11 |
12 namespace base { | 12 class SharedIOBuffer; |
13 class SharedMemory; | |
14 } | |
15 | 13 |
16 // Used to complete an asynchronous resource request in response to resource | 14 // Used to complete an asynchronous resource request in response to resource |
17 // load events from the resource dispatcher host. | 15 // load events from the resource dispatcher host. |
18 class AsyncResourceHandler : public ResourceHandler { | 16 class AsyncResourceHandler : public ResourceHandler { |
19 public: | 17 public: |
20 AsyncResourceHandler(ResourceDispatcherHost::Receiver* receiver, | 18 AsyncResourceHandler(ResourceDispatcherHost::Receiver* receiver, |
21 int render_process_host_id, | 19 int render_process_host_id, |
22 int routing_id, | 20 int routing_id, |
23 base::ProcessHandle render_process, | 21 base::ProcessHandle render_process, |
24 const GURL& url, | 22 const GURL& url, |
25 ResourceDispatcherHost* resource_dispatcher_host); | 23 ResourceDispatcherHost* resource_dispatcher_host); |
26 | 24 |
27 // ResourceHandler implementation: | 25 // ResourceHandler implementation: |
28 bool OnUploadProgress(int request_id, uint64 position, uint64 size); | 26 bool OnUploadProgress(int request_id, uint64 position, uint64 size); |
29 bool OnRequestRedirected(int request_id, const GURL& new_url); | 27 bool OnRequestRedirected(int request_id, const GURL& new_url); |
30 bool OnResponseStarted(int request_id, ResourceResponse* response); | 28 bool OnResponseStarted(int request_id, ResourceResponse* response); |
31 bool OnWillRead(int request_id, char** buf, int* buf_size, int min_size); | 29 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
| 30 int min_size); |
32 bool OnReadCompleted(int request_id, int* bytes_read); | 31 bool OnReadCompleted(int request_id, int* bytes_read); |
33 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); | 32 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); |
34 | 33 |
35 static void GlobalCleanup(); | 34 static void GlobalCleanup(); |
36 | 35 |
37 private: | 36 private: |
38 // When reading, we don't know if we are going to get EOF (0 bytes read), so | 37 // When reading, we don't know if we are going to get EOF (0 bytes read), so |
39 // we typically have a buffer that we allocated but did not use. We keep | 38 // we typically have a buffer that we allocated but did not use. We keep |
40 // this buffer around for the next read as a small optimization. | 39 // this buffer around for the next read as a small optimization. |
41 static base::SharedMemory* spare_read_buffer_; | 40 static SharedIOBuffer* spare_read_buffer_; |
42 | 41 |
43 scoped_ptr<base::SharedMemory> read_buffer_; | 42 scoped_refptr<SharedIOBuffer> read_buffer_; |
44 ResourceDispatcherHost::Receiver* receiver_; | 43 ResourceDispatcherHost::Receiver* receiver_; |
45 int render_process_host_id_; | 44 int render_process_host_id_; |
46 int routing_id_; | 45 int routing_id_; |
47 base::ProcessHandle render_process_; | 46 base::ProcessHandle render_process_; |
48 ResourceDispatcherHost* rdh_; | 47 ResourceDispatcherHost* rdh_; |
49 | 48 |
50 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); | 49 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); |
51 }; | 50 }; |
52 | 51 |
53 #endif // CHROME_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ | 52 #endif // CHROME_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ |
OLD | NEW |