Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/renderer_host/async_resource_handler.h

Issue 5874002: Create a ResourceMessageFilter to filter resource related IPCs. This gets ri... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/process.h"
12 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
13 #include "chrome/browser/renderer_host/resource_handler.h" 11 #include "chrome/browser/renderer_host/resource_handler.h"
14 12
13 class ResourceDispatcherHost;
14 class ResourceMessageFilter;
15 class SharedIOBuffer; 15 class SharedIOBuffer;
16 16
17 // Used to complete an asynchronous resource request in response to resource 17 // Used to complete an asynchronous resource request in response to resource
18 // load events from the resource dispatcher host. 18 // load events from the resource dispatcher host.
19 class AsyncResourceHandler : public ResourceHandler { 19 class AsyncResourceHandler : public ResourceHandler {
20 public: 20 public:
21 AsyncResourceHandler(ResourceDispatcherHost::Receiver* receiver, 21 AsyncResourceHandler(ResourceMessageFilter* filter,
22 int process_id,
23 int routing_id, 22 int routing_id,
24 base::ProcessHandle process_handle,
25 const GURL& url, 23 const GURL& url,
26 ResourceDispatcherHost* resource_dispatcher_host); 24 ResourceDispatcherHost* resource_dispatcher_host);
27 25
28 // ResourceHandler implementation: 26 // ResourceHandler implementation:
29 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); 27 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size);
30 virtual bool OnRequestRedirected(int request_id, const GURL& new_url, 28 virtual bool OnRequestRedirected(int request_id, const GURL& new_url,
31 ResourceResponse* response, bool* defer); 29 ResourceResponse* response, bool* defer);
32 virtual bool OnResponseStarted(int request_id, ResourceResponse* response); 30 virtual bool OnResponseStarted(int request_id, ResourceResponse* response);
33 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); 31 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer);
34 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, 32 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size,
35 int min_size); 33 int min_size);
36 virtual bool OnReadCompleted(int request_id, int* bytes_read); 34 virtual bool OnReadCompleted(int request_id, int* bytes_read);
37 virtual bool OnResponseCompleted(int request_id, 35 virtual bool OnResponseCompleted(int request_id,
38 const URLRequestStatus& status, 36 const URLRequestStatus& status,
39 const std::string& security_info); 37 const std::string& security_info);
40 virtual void OnRequestClosed(); 38 virtual void OnRequestClosed();
41 virtual void OnDataDownloaded(int request_id, int bytes_downloaded); 39 virtual void OnDataDownloaded(int request_id, int bytes_downloaded);
42 40
43 static void GlobalCleanup(); 41 static void GlobalCleanup();
44 42
45 private: 43 private:
46 virtual ~AsyncResourceHandler(); 44 virtual ~AsyncResourceHandler();
47 45
48 scoped_refptr<SharedIOBuffer> read_buffer_; 46 scoped_refptr<SharedIOBuffer> read_buffer_;
49 ResourceDispatcherHost::Receiver* receiver_; 47 ResourceMessageFilter* filter_;
50 int process_id_;
51 int routing_id_; 48 int routing_id_;
52 base::ProcessHandle process_handle_;
53 ResourceDispatcherHost* rdh_; 49 ResourceDispatcherHost* rdh_;
54 50
55 // |next_buffer_size_| is the size of the buffer to be allocated on the next 51 // |next_buffer_size_| is the size of the buffer to be allocated on the next
56 // OnWillRead() call. We exponentially grow the size of the buffer allocated 52 // OnWillRead() call. We exponentially grow the size of the buffer allocated
57 // when our owner fills our buffers. On the first OnWillRead() call, we 53 // when our owner fills our buffers. On the first OnWillRead() call, we
58 // allocate a buffer of 32k and double it in OnReadCompleted() if the buffer 54 // allocate a buffer of 32k and double it in OnReadCompleted() if the buffer
59 // was filled, up to a maximum size of 512k. 55 // was filled, up to a maximum size of 512k.
60 int next_buffer_size_; 56 int next_buffer_size_;
61 57
62 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); 58 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler);
63 }; 59 };
64 60
65 #endif // CHROME_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ 61 #endif // CHROME_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698