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

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

Issue 10911297: Modify AsyncResourceHandler to use a single shared memory buffer (in ring (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 7
8 #include <string> 8 #include <string>
9 9
10 #include "content/browser/renderer_host/resource_handler.h" 10 #include "content/browser/renderer_host/resource_handler.h"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 12
13 namespace net { 13 namespace net {
14 class URLRequest; 14 class URLRequest;
15 } 15 }
16 16
17 namespace content { 17 namespace content {
18 class ResourceBuffer;
18 class ResourceDispatcherHostImpl; 19 class ResourceDispatcherHostImpl;
19 class ResourceMessageFilter; 20 class ResourceMessageFilter;
20 class SharedIOBuffer; 21 class SharedIOBuffer;
21 22
22 // Used to complete an asynchronous resource request in response to resource 23 // Used to complete an asynchronous resource request in response to resource
23 // load events from the resource dispatcher host. 24 // load events from the resource dispatcher host.
24 class AsyncResourceHandler : public ResourceHandler { 25 class AsyncResourceHandler : public ResourceHandler {
25 public: 26 public:
26 AsyncResourceHandler(ResourceMessageFilter* filter, 27 AsyncResourceHandler(ResourceMessageFilter* filter,
27 int routing_id, 28 int routing_id,
(...skipping 26 matching lines...) Expand all
54 int min_size) OVERRIDE; 55 int min_size) OVERRIDE;
55 virtual bool OnReadCompleted(int request_id, 56 virtual bool OnReadCompleted(int request_id,
56 int bytes_read, 57 int bytes_read,
57 bool* defer) OVERRIDE; 58 bool* defer) OVERRIDE;
58 virtual bool OnResponseCompleted(int request_id, 59 virtual bool OnResponseCompleted(int request_id,
59 const net::URLRequestStatus& status, 60 const net::URLRequestStatus& status,
60 const std::string& security_info) OVERRIDE; 61 const std::string& security_info) OVERRIDE;
61 virtual void OnDataDownloaded(int request_id, 62 virtual void OnDataDownloaded(int request_id,
62 int bytes_downloaded) OVERRIDE; 63 int bytes_downloaded) OVERRIDE;
63 64
64 static void GlobalCleanup();
65
66 private: 65 private:
67 // Returns true if it's ok to send the data. If there are already too many 66 bool EnsureResourceBufferIsInitialized();
68 // data messages pending, it defers the request and returns false. In this
69 // case the caller should not send the data.
70 void WillSendData(bool* defer);
71
72 void ResumeIfDeferred(); 67 void ResumeIfDeferred();
73 68
74 scoped_refptr<SharedIOBuffer> read_buffer_; 69 scoped_refptr<ResourceBuffer> buffer_;
75 scoped_refptr<ResourceMessageFilter> filter_; 70 scoped_refptr<ResourceMessageFilter> filter_;
76 int routing_id_; 71 int routing_id_;
77 net::URLRequest* request_; 72 net::URLRequest* request_;
78 ResourceDispatcherHostImpl* rdh_; 73 ResourceDispatcherHostImpl* rdh_;
79 74
80 // |next_buffer_size_| is the size of the buffer to be allocated on the next
81 // OnWillRead() call. We exponentially grow the size of the buffer allocated
82 // when our owner fills our buffers. On the first OnWillRead() call, we
83 // allocate a buffer of 32k and double it in OnReadCompleted() if the buffer
84 // was filled, up to a maximum size of 512k.
85 int next_buffer_size_;
86
87 // Number of messages we've sent to the renderer that we haven't gotten an 75 // Number of messages we've sent to the renderer that we haven't gotten an
88 // ACK for. This allows us to avoid having too many messages in flight. 76 // ACK for. This allows us to avoid having too many messages in flight.
89 int pending_data_count_; 77 int pending_data_count_;
90 78
79 int allocation_size_;
80
91 bool did_defer_; 81 bool did_defer_;
92 82
93 bool sent_received_response_msg_; 83 bool sent_received_response_msg_;
84 bool sent_first_data_msg_;
94 85
95 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); 86 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler);
96 }; 87 };
97 88
98 } // namespace content 89 } // namespace content
99 90
100 #endif // CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ 91 #endif // CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698