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

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

Issue 6532073: Move core pieces of browser\renderer_host to src\content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 // TODO(jam): remove this file when all files have been converted.
10 10 #include "content/browser/renderer_host/buffered_resource_handler.h"
11 #include "chrome/browser/renderer_host/resource_handler.h"
12
13 class MessageLoop;
14 class ResourceDispatcherHost;
15
16 namespace net {
17 class URLRequest;
18 } // namespace net
19
20 // Used to buffer a request until enough data has been received.
21 class BufferedResourceHandler : public ResourceHandler {
22 public:
23 BufferedResourceHandler(ResourceHandler* handler,
24 ResourceDispatcherHost* host,
25 net::URLRequest* request);
26
27 // ResourceHandler implementation:
28 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size);
29 virtual bool OnRequestRedirected(int request_id, const GURL& new_url,
30 ResourceResponse* response, bool* defer);
31 virtual bool OnResponseStarted(int request_id, ResourceResponse* response);
32 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer);
33 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size,
34 int min_size);
35 virtual bool OnReadCompleted(int request_id, int* bytes_read);
36 virtual bool OnResponseCompleted(int request_id,
37 const net::URLRequestStatus& status,
38 const std::string& security_info);
39 virtual void OnRequestClosed();
40
41 private:
42 virtual ~BufferedResourceHandler();
43
44 // Returns true if we should delay OnResponseStarted forwarding.
45 bool DelayResponse();
46
47 // Returns true if there will be a need to parse the DocType of the document
48 // to determine the right way to handle it.
49 bool ShouldBuffer(const GURL& url, const std::string& mime_type);
50
51 // Returns true if there is enough information to process the DocType.
52 bool DidBufferEnough(int bytes_read);
53
54 // Returns true if we have to keep buffering data.
55 bool KeepBuffering(int bytes_read);
56
57 // Sends a pending OnResponseStarted notification. |in_complete| is true if
58 // this is invoked from |OnResponseCompleted|.
59 bool CompleteResponseStarted(int request_id, bool in_complete);
60
61 // Returns true if we have to wait until the plugin list is generated.
62 bool ShouldWaitForPlugins();
63
64 // A test to determining whether the request should be forwarded to the
65 // download thread. If need_plugin_list was passed in and was set to true,
66 // that means that the check couldn't be fully done because the plugins aren't
67 // loaded. The function should be called again after the plugin list is
68 // loaded.
69 bool ShouldDownload(bool* need_plugin_list);
70
71 // Informs the original ResourceHandler |real_handler_| that the response will
72 // be handled entirely by the new ResourceHandler |handler|.
73 // A reference to |handler| is acquired.
74 void UseAlternateResourceHandler(int request_id, ResourceHandler* handler);
75
76 // Called on the file thread to load the list of plugins.
77 void LoadPlugins();
78
79 // Called on the IO thread once the list of plugins has been loaded.
80 void OnPluginsLoaded();
81
82 scoped_refptr<ResourceHandler> real_handler_;
83 scoped_refptr<ResourceResponse> response_;
84 ResourceDispatcherHost* host_;
85 net::URLRequest* request_;
86 scoped_refptr<net::IOBuffer> read_buffer_;
87 scoped_refptr<net::IOBuffer> my_buffer_;
88 int read_buffer_size_;
89 int bytes_read_;
90 bool sniff_content_;
91 bool should_buffer_;
92 bool wait_for_plugins_;
93 bool buffering_;
94 bool finished_;
95
96 DISALLOW_COPY_AND_ASSIGN(BufferedResourceHandler);
97 };
98 11
99 #endif // CHROME_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_ 12 #endif // CHROME_BROWSER_RENDERER_HOST_BUFFERED_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698