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

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

Issue 18390: Change URLRequest to use a ref-counted buffer for actual IO.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months 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_BUFFERED_RESOURCE_HANDLER_H_ 5 #ifndef CHROME_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_
6 #define CHROME_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_ 6 #define CHROME_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/renderer_host/resource_handler.h" 10 #include "chrome/browser/renderer_host/resource_handler.h"
11 11
12 class ResourceDispatcherHost; 12 class ResourceDispatcherHost;
13 13
14 // Used to buffer a request until enough data has been received. 14 // Used to buffer a request until enough data has been received.
15 class BufferedResourceHandler : public ResourceHandler { 15 class BufferedResourceHandler : public ResourceHandler {
16 public: 16 public:
17 BufferedResourceHandler(ResourceHandler* handler, 17 BufferedResourceHandler(ResourceHandler* handler,
18 ResourceDispatcherHost* host, 18 ResourceDispatcherHost* host,
19 URLRequest* request); 19 URLRequest* request);
20 20
21 // ResourceHandler implementation: 21 // ResourceHandler implementation:
22 bool OnUploadProgress(int request_id, uint64 position, uint64 size); 22 bool OnUploadProgress(int request_id, uint64 position, uint64 size);
23 bool OnRequestRedirected(int request_id, const GURL& new_url); 23 bool OnRequestRedirected(int request_id, const GURL& new_url);
24 bool OnResponseStarted(int request_id, ResourceResponse* response); 24 bool OnResponseStarted(int request_id, ResourceResponse* response);
25 bool OnWillRead(int request_id, char** buf, int* buf_size, int min_size); 25 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size,
26 int min_size);
26 bool OnReadCompleted(int request_id, int* bytes_read); 27 bool OnReadCompleted(int request_id, int* bytes_read);
27 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); 28 bool OnResponseCompleted(int request_id, const URLRequestStatus& status);
28 29
29 private: 30 private:
30 // Returns true if we should delay OnResponseStarted forwarding. 31 // Returns true if we should delay OnResponseStarted forwarding.
31 bool DelayResponse(); 32 bool DelayResponse();
32 33
33 // Returns true if there will be a need to parse the DocType of the document 34 // Returns true if there will be a need to parse the DocType of the document
34 // to determine the right way to handle it. 35 // to determine the right way to handle it.
35 bool ShouldBuffer(const GURL& url, const std::string& mime_type); 36 bool ShouldBuffer(const GURL& url, const std::string& mime_type);
36 37
37 // Returns true if there is enough information to process the DocType. 38 // Returns true if there is enough information to process the DocType.
38 bool DidBufferEnough(int bytes_read); 39 bool DidBufferEnough(int bytes_read);
39 40
40 // Returns true if we have to keep buffering data. 41 // Returns true if we have to keep buffering data.
41 bool KeepBuffering(int bytes_read); 42 bool KeepBuffering(int bytes_read);
42 43
43 // Sends a pending OnResponseStarted notification. |in_complete| is true if 44 // Sends a pending OnResponseStarted notification. |in_complete| is true if
44 // this is invoked from |OnResponseCompleted|. 45 // this is invoked from |OnResponseCompleted|.
45 bool CompleteResponseStarted(int request_id, bool in_complete); 46 bool CompleteResponseStarted(int request_id, bool in_complete);
46 47
47 scoped_refptr<ResourceHandler> real_handler_; 48 scoped_refptr<ResourceHandler> real_handler_;
48 scoped_refptr<ResourceResponse> response_; 49 scoped_refptr<ResourceResponse> response_;
49 ResourceDispatcherHost* host_; 50 ResourceDispatcherHost* host_;
50 URLRequest* request_; 51 URLRequest* request_;
51 char* read_buffer_; 52 scoped_refptr<net::IOBuffer> read_buffer_;
53 scoped_refptr<net::IOBuffer> my_buffer_;
52 int read_buffer_size_; 54 int read_buffer_size_;
53 int bytes_read_; 55 int bytes_read_;
54 bool sniff_content_; 56 bool sniff_content_;
55 bool should_buffer_; 57 bool should_buffer_;
56 bool buffering_; 58 bool buffering_;
57 bool finished_; 59 bool finished_;
58 60
59 DISALLOW_COPY_AND_ASSIGN(BufferedResourceHandler); 61 DISALLOW_COPY_AND_ASSIGN(BufferedResourceHandler);
60 }; 62 };
61 63
62 #endif // CHROME_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_ 64 #endif // CHROME_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/async_resource_handler.cc ('k') | chrome/browser/renderer_host/buffered_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698