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

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

Issue 10644011: Revert r143458 (which re-applies r143341 and r142979). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
11 #include "content/browser/renderer_host/resource_handler.h" 11 #include "content/browser/renderer_host/resource_handler.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 13
14 namespace net {
15 class URLRequest;
16 }
17
14 namespace content { 18 namespace content {
15 class ResourceDispatcherHostImpl; 19 class ResourceDispatcherHostImpl;
16 class ResourceMessageFilter; 20 class ResourceMessageFilter;
17 class SharedIOBuffer; 21 class SharedIOBuffer;
18 22
19 // Used to complete an asynchronous resource request in response to resource 23 // Used to complete an asynchronous resource request in response to resource
20 // load events from the resource dispatcher host. 24 // load events from the resource dispatcher host.
21 class AsyncResourceHandler : public ResourceHandler { 25 class AsyncResourceHandler : public ResourceHandler {
22 public: 26 public:
23 AsyncResourceHandler(ResourceMessageFilter* filter, 27 AsyncResourceHandler(ResourceMessageFilter* filter,
24 int routing_id, 28 int routing_id,
25 const GURL& url, 29 net::URLRequest* request,
26 ResourceDispatcherHostImpl* rdh); 30 ResourceDispatcherHostImpl* rdh);
27 virtual ~AsyncResourceHandler(); 31 virtual ~AsyncResourceHandler();
28 32
33 // IPC message handlers:
34 void OnFollowRedirect(bool has_new_first_party_for_cookies,
35 const GURL& new_first_party_for_cookies);
36 void OnDataReceivedACK();
37
29 // ResourceHandler implementation: 38 // ResourceHandler implementation:
30 virtual bool OnUploadProgress(int request_id, 39 virtual bool OnUploadProgress(int request_id,
31 uint64 position, 40 uint64 position,
32 uint64 size) OVERRIDE; 41 uint64 size) OVERRIDE;
33 virtual bool OnRequestRedirected(int request_id, 42 virtual bool OnRequestRedirected(int request_id,
34 const GURL& new_url, 43 const GURL& new_url,
35 ResourceResponse* response, 44 ResourceResponse* response,
36 bool* defer) OVERRIDE; 45 bool* defer) OVERRIDE;
37 virtual bool OnResponseStarted(int request_id, 46 virtual bool OnResponseStarted(int request_id,
38 ResourceResponse* response, 47 ResourceResponse* response,
(...skipping 10 matching lines...) Expand all
49 bool* defer) OVERRIDE; 58 bool* defer) OVERRIDE;
50 virtual bool OnResponseCompleted(int request_id, 59 virtual bool OnResponseCompleted(int request_id,
51 const net::URLRequestStatus& status, 60 const net::URLRequestStatus& status,
52 const std::string& security_info) OVERRIDE; 61 const std::string& security_info) OVERRIDE;
53 virtual void OnDataDownloaded(int request_id, 62 virtual void OnDataDownloaded(int request_id,
54 int bytes_downloaded) OVERRIDE; 63 int bytes_downloaded) OVERRIDE;
55 64
56 static void GlobalCleanup(); 65 static void GlobalCleanup();
57 66
58 private: 67 private:
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
70 // case the caller should not send the data.
71 bool WillSendData(bool* defer);
72
73 void ResumeIfDeferred();
74
59 scoped_refptr<SharedIOBuffer> read_buffer_; 75 scoped_refptr<SharedIOBuffer> read_buffer_;
60 scoped_refptr<ResourceMessageFilter> filter_; 76 scoped_refptr<ResourceMessageFilter> filter_;
61 int routing_id_; 77 int routing_id_;
78 net::URLRequest* request_;
62 ResourceDispatcherHostImpl* rdh_; 79 ResourceDispatcherHostImpl* rdh_;
63 80
64 // |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
65 // OnWillRead() call. We exponentially grow the size of the buffer allocated 82 // OnWillRead() call. We exponentially grow the size of the buffer allocated
66 // 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
67 // 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
68 // was filled, up to a maximum size of 512k. 85 // was filled, up to a maximum size of 512k.
69 int next_buffer_size_; 86 int next_buffer_size_;
70 87
71 // TODO(battre): Remove url. This is only for debugging 88 // Number of messages we've sent to the renderer that we haven't gotten an
72 // http://crbug.com/107692. 89 // ACK for. This allows us to avoid having too many messages in flight.
73 GURL url_; 90 int pending_data_count_;
91
92 bool did_defer_;
74 93
75 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler); 94 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler);
76 }; 95 };
77 96
78 } // namespace content 97 } // namespace content
79 98
80 #endif // CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_ 99 #endif // CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698