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

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

Issue 10332130: Use defer out-params instead of ResourceDispatcherHostImpl::PauseRequest(...true) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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_BUFFERED_RESOURCE_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 13 matching lines...) Expand all
24 24
25 // Used to buffer a request until enough data has been received. 25 // Used to buffer a request until enough data has been received.
26 class BufferedResourceHandler : public LayeredResourceHandler { 26 class BufferedResourceHandler : public LayeredResourceHandler {
27 public: 27 public:
28 BufferedResourceHandler(ResourceHandler* handler, 28 BufferedResourceHandler(ResourceHandler* handler,
29 ResourceDispatcherHostImpl* host, 29 ResourceDispatcherHostImpl* host,
30 net::URLRequest* request); 30 net::URLRequest* request);
31 31
32 // ResourceHandler implementation: 32 // ResourceHandler implementation:
33 virtual bool OnResponseStarted(int request_id, 33 virtual bool OnResponseStarted(int request_id,
34 ResourceResponse* response) OVERRIDE; 34 ResourceResponse* response,
35 bool* defer) OVERRIDE;
35 virtual bool OnWillRead(int request_id, 36 virtual bool OnWillRead(int request_id,
36 net::IOBuffer** buf, 37 net::IOBuffer** buf,
37 int* buf_size, 38 int* buf_size,
38 int min_size) OVERRIDE; 39 int min_size) OVERRIDE;
39 virtual bool OnReadCompleted(int request_id, int* bytes_read) OVERRIDE; 40 virtual bool OnReadCompleted(int request_id, int* bytes_read,
41 bool* defer) OVERRIDE;
40 virtual void OnRequestClosed() OVERRIDE; 42 virtual void OnRequestClosed() OVERRIDE;
41 43
42 private: 44 private:
43 virtual ~BufferedResourceHandler(); 45 virtual ~BufferedResourceHandler();
44 46
45 // Returns true if we should delay OnResponseStarted forwarding. 47 // Returns true if we should delay OnResponseStarted forwarding.
46 bool DelayResponse(); 48 bool DelayResponse();
47 49
48 // Returns true if there is enough information to process the DocType. 50 // Returns true if there is enough information to process the DocType.
49 bool DidBufferEnough(int bytes_read); 51 bool DidBufferEnough(int bytes_read);
50 52
51 // Returns true if we have to keep buffering data. 53 // Returns true if we have to keep buffering data.
52 bool KeepBuffering(int bytes_read); 54 bool KeepBuffering(int bytes_read);
53 55
54 // Sends a pending OnResponseStarted notification. 56 // Sends a pending OnResponseStarted notification.
55 bool CompleteResponseStarted(int request_id); 57 bool CompleteResponseStarted(int request_id, bool* defer);
56 58
57 // Returns true if we have to wait until the plugin list is generated. 59 // Returns true if we have to wait until the plugin list is generated.
58 bool ShouldWaitForPlugins(); 60 bool ShouldWaitForPlugins();
59 61
60 // A test to determining whether the request should be forwarded to the 62 // A test to determining whether the request should be forwarded to the
61 // download thread. If need_plugin_list was passed in and was set to true, 63 // download thread. If need_plugin_list was passed in and was set to true,
62 // that means that the check couldn't be fully done because the plugins aren't 64 // that means that the check couldn't be fully done because the plugins aren't
63 // loaded. The function should be called again after the plugin list is 65 // loaded. The function should be called again after the plugin list is
64 // loaded. 66 // loaded.
65 bool ShouldDownload(bool* need_plugin_list); 67 bool ShouldDownload(bool* need_plugin_list);
66 68
67 // Informs the original ResourceHandler |next_handler_| that the response 69 // Informs the original ResourceHandler |next_handler_| that the response
68 // will be handled entirely by the new ResourceHandler |handler|. A 70 // will be handled entirely by the new ResourceHandler |handler|. A
69 // reference to |handler| is acquired. Returns false to indicate an error, 71 // reference to |handler| is acquired. Returns false to indicate an error,
70 // which will result in the request being cancelled. 72 // which will result in the request being cancelled.
71 bool UseAlternateResourceHandler(int request_id, ResourceHandler* handler); 73 bool UseAlternateResourceHandler(int request_id, ResourceHandler* handler,
74 bool* defer);
72 75
73 // Forwards any queued events to |next_handler_|. Returns false to indicate 76 // Forwards any queued events to |next_handler_|. Returns false to indicate
74 // an error, which will result in the request being cancelled. 77 // an error, which will result in the request being cancelled.
75 bool ForwardPendingEventsToNextHandler(int request_id); 78 bool ForwardPendingEventsToNextHandler(int request_id, bool* defer);
76 79
77 // Copies data from |read_buffer_| to |next_handler_|. 80 // Copies data from |read_buffer_| to |next_handler_|.
78 void CopyReadBufferToNextHandler(int request_id); 81 void CopyReadBufferToNextHandler(int request_id);
79 82
80 // Called on the IO thread once the list of plugins has been loaded. 83 // Called on the IO thread once the list of plugins has been loaded.
81 void OnPluginsLoaded(const std::vector<webkit::WebPluginInfo>& plugins); 84 void OnPluginsLoaded(const std::vector<webkit::WebPluginInfo>& plugins);
82 85
83 scoped_refptr<ResourceResponse> response_; 86 scoped_refptr<ResourceResponse> response_;
84 ResourceDispatcherHostImpl* host_; 87 ResourceDispatcherHostImpl* host_;
85 net::URLRequest* request_; 88 net::URLRequest* request_;
86 scoped_refptr<net::IOBuffer> read_buffer_; 89 scoped_refptr<net::IOBuffer> read_buffer_;
87 scoped_refptr<net::IOBuffer> my_buffer_; 90 scoped_refptr<net::IOBuffer> my_buffer_;
88 int read_buffer_size_; 91 int read_buffer_size_;
89 int bytes_read_; 92 int bytes_read_;
90 bool sniff_content_; 93 bool sniff_content_;
91 bool wait_for_plugins_; 94 bool wait_for_plugins_;
95 bool deferred_waiting_for_plugins_;
92 bool buffering_; 96 bool buffering_;
93 bool next_handler_needs_response_started_; 97 bool next_handler_needs_response_started_;
94 bool next_handler_needs_will_read_; 98 bool next_handler_needs_will_read_;
95 bool finished_; 99 bool finished_;
96 100
97 DISALLOW_COPY_AND_ASSIGN(BufferedResourceHandler); 101 DISALLOW_COPY_AND_ASSIGN(BufferedResourceHandler);
98 }; 102 };
99 103
100 } // namespace content 104 } // namespace content
101 105
102 #endif // CONTENT_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_ 106 #endif // CONTENT_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/async_resource_handler.cc ('k') | content/browser/renderer_host/buffered_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698