OLD | NEW |
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_LOADER_BUFFERED_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_BUFFERED_RESOURCE_HANDLER_H_ |
6 #define CONTENT_BROWSER_LOADER_BUFFERED_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_BUFFERED_RESOURCE_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "content/browser/loader/layered_resource_handler.h" | 12 #include "content/browser/loader/layered_resource_handler.h" |
13 #include "content/public/browser/resource_controller.h" | 13 #include "content/public/browser/resource_controller.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 class URLRequest; | 16 class URLRequest; |
17 } | 17 } |
18 | 18 |
19 namespace webkit { | |
20 struct WebPluginInfo; | |
21 } | |
22 | |
23 namespace content { | 19 namespace content { |
24 class ResourceDispatcherHostImpl; | 20 class ResourceDispatcherHostImpl; |
| 21 struct WebPluginInfo; |
25 | 22 |
26 // Used to buffer a request until enough data has been received. | 23 // Used to buffer a request until enough data has been received. |
27 class BufferedResourceHandler | 24 class BufferedResourceHandler |
28 : public LayeredResourceHandler, | 25 : public LayeredResourceHandler, |
29 public ResourceController { | 26 public ResourceController { |
30 public: | 27 public: |
31 BufferedResourceHandler(scoped_ptr<ResourceHandler> next_handler, | 28 BufferedResourceHandler(scoped_ptr<ResourceHandler> next_handler, |
32 ResourceDispatcherHostImpl* host, | 29 ResourceDispatcherHostImpl* host, |
33 net::URLRequest* request); | 30 net::URLRequest* request); |
34 virtual ~BufferedResourceHandler(); | 31 virtual ~BufferedResourceHandler(); |
(...skipping 30 matching lines...) Expand all Loading... |
65 bool ReplayReadCompleted(bool* defer); | 62 bool ReplayReadCompleted(bool* defer); |
66 void CallReplayReadCompleted(); | 63 void CallReplayReadCompleted(); |
67 | 64 |
68 bool MustDownload(); | 65 bool MustDownload(); |
69 bool HasSupportingPlugin(bool* is_stale); | 66 bool HasSupportingPlugin(bool* is_stale); |
70 | 67 |
71 // Copies data from |read_buffer_| to |next_handler_|. | 68 // Copies data from |read_buffer_| to |next_handler_|. |
72 bool CopyReadBufferToNextHandler(int request_id); | 69 bool CopyReadBufferToNextHandler(int request_id); |
73 | 70 |
74 // Called on the IO thread once the list of plugins has been loaded. | 71 // Called on the IO thread once the list of plugins has been loaded. |
75 void OnPluginsLoaded(const std::vector<webkit::WebPluginInfo>& plugins); | 72 void OnPluginsLoaded(const std::vector<WebPluginInfo>& plugins); |
76 | 73 |
77 enum State { | 74 enum State { |
78 STATE_STARTING, | 75 STATE_STARTING, |
79 | 76 |
80 // In this state, we are filling read_buffer_ with data for the purpose | 77 // In this state, we are filling read_buffer_ with data for the purpose |
81 // of sniffing the mime type of the response. | 78 // of sniffing the mime type of the response. |
82 STATE_BUFFERING, | 79 STATE_BUFFERING, |
83 | 80 |
84 // In this state, we are select an appropriate downstream ResourceHandler | 81 // In this state, we are select an appropriate downstream ResourceHandler |
85 // based on the mime type of the response. We are also potentially waiting | 82 // based on the mime type of the response. We are also potentially waiting |
(...skipping 21 matching lines...) Expand all Loading... |
107 bool must_download_is_set_; | 104 bool must_download_is_set_; |
108 | 105 |
109 base::WeakPtrFactory<BufferedResourceHandler> weak_ptr_factory_; | 106 base::WeakPtrFactory<BufferedResourceHandler> weak_ptr_factory_; |
110 | 107 |
111 DISALLOW_COPY_AND_ASSIGN(BufferedResourceHandler); | 108 DISALLOW_COPY_AND_ASSIGN(BufferedResourceHandler); |
112 }; | 109 }; |
113 | 110 |
114 } // namespace content | 111 } // namespace content |
115 | 112 |
116 #endif // CONTENT_BROWSER_LOADER_BUFFERED_RESOURCE_HANDLER_H_ | 113 #endif // CONTENT_BROWSER_LOADER_BUFFERED_RESOURCE_HANDLER_H_ |
OLD | NEW |