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

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

Issue 10578055: Rewrite guts of ResourceLoader and BufferedResourceHandler to suck less. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 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_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 ResourceResponse* response, 47 ResourceResponse* response,
48 bool* defer) OVERRIDE; 48 bool* defer) OVERRIDE;
49 virtual bool OnWillStart(int request_id, 49 virtual bool OnWillStart(int request_id,
50 const GURL& url, 50 const GURL& url,
51 bool* defer) OVERRIDE; 51 bool* defer) OVERRIDE;
52 virtual bool OnWillRead(int request_id, 52 virtual bool OnWillRead(int request_id,
53 net::IOBuffer** buf, 53 net::IOBuffer** buf,
54 int* buf_size, 54 int* buf_size,
55 int min_size) OVERRIDE; 55 int min_size) OVERRIDE;
56 virtual bool OnReadCompleted(int request_id, 56 virtual bool OnReadCompleted(int request_id,
57 int* bytes_read, 57 int bytes_read,
58 bool* defer) OVERRIDE; 58 bool* defer) OVERRIDE;
59 virtual bool OnResponseCompleted(int request_id, 59 virtual bool OnResponseCompleted(int request_id,
60 const net::URLRequestStatus& status, 60 const net::URLRequestStatus& status,
61 const std::string& security_info) OVERRIDE; 61 const std::string& security_info) OVERRIDE;
62 virtual void OnDataDownloaded(int request_id, 62 virtual void OnDataDownloaded(int request_id,
63 int bytes_downloaded) OVERRIDE; 63 int bytes_downloaded) OVERRIDE;
64 64
65 static void GlobalCleanup(); 65 static void GlobalCleanup();
66 66
67 private: 67 private:
68 // Returns true if it's ok to send the data. If there are already too many 68 // Returns true if it's ok to send the data. If there are already too many
69 // data messages pending, it defers the request and returns false. In this 69 // data messages pending, it defers the request and returns false. In this
70 // case the caller should not send the data. 70 // case the caller should not send the data.
71 bool WillSendData(bool* defer); 71 void WillSendData(bool* defer);
72 72
73 void ResumeIfDeferred(); 73 void ResumeIfDeferred();
74 74
75 scoped_refptr<SharedIOBuffer> read_buffer_; 75 scoped_refptr<SharedIOBuffer> read_buffer_;
76 scoped_refptr<ResourceMessageFilter> filter_; 76 scoped_refptr<ResourceMessageFilter> filter_;
77 int routing_id_; 77 int routing_id_;
78 net::URLRequest* request_; 78 net::URLRequest* request_;
79 ResourceDispatcherHostImpl* rdh_; 79 ResourceDispatcherHostImpl* rdh_;
80 80
81 // |next_buffer_size_| is the size of the buffer to be allocated on the next 81 // |next_buffer_size_| is the size of the buffer to be allocated on the next
82 // OnWillRead() call. We exponentially grow the size of the buffer allocated 82 // OnWillRead() call. We exponentially grow the size of the buffer allocated
83 // when our owner fills our buffers. On the first OnWillRead() call, we 83 // when our owner fills our buffers. On the first OnWillRead() call, we
84 // allocate a buffer of 32k and double it in OnReadCompleted() if the buffer 84 // allocate a buffer of 32k and double it in OnReadCompleted() if the buffer
85 // was filled, up to a maximum size of 512k. 85 // was filled, up to a maximum size of 512k.
86 int next_buffer_size_; 86 int next_buffer_size_;
87 87
88 // Number of messages we've sent to the renderer that we haven't gotten an 88 // Number of messages we've sent to the renderer that we haven't gotten an
89 // ACK for. This allows us to avoid having too many messages in flight. 89 // ACK for. This allows us to avoid having too many messages in flight.
90 int pending_data_count_; 90 int pending_data_count_;
91 91
92 bool did_defer_; 92 bool did_defer_;
93 93
94 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); 94 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler);
95 }; 95 };
96 96
97 } // namespace content 97 } // namespace content
98 98
99 #endif // CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ 99 #endif // CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/download/save_file_resource_handler.cc ('k') | content/browser/renderer_host/async_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698