OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/loader/buffered_resource_handler.h" | 5 #include "content/browser/loader/buffered_resource_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 10 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 net::URLRequest* request, | 92 net::URLRequest* request, |
93 bool is_content_initiated, | 93 bool is_content_initiated, |
94 bool must_download, | 94 bool must_download, |
95 uint32 id, | 95 uint32 id, |
96 scoped_ptr<DownloadSaveInfo> save_info, | 96 scoped_ptr<DownloadSaveInfo> save_info, |
97 const DownloadUrlParameters::OnStartedCallback& started_cb) override { | 97 const DownloadUrlParameters::OnStartedCallback& started_cb) override { |
98 return scoped_ptr<ResourceHandler>(new TestResourceHandler).Pass(); | 98 return scoped_ptr<ResourceHandler>(new TestResourceHandler).Pass(); |
99 } | 99 } |
100 | 100 |
101 scoped_ptr<ResourceHandler> MaybeInterceptAsStream( | 101 scoped_ptr<ResourceHandler> MaybeInterceptAsStream( |
102 const base::FilePath& file_path, | |
raymes
2015/03/12 05:21:03
plugin_path
Deepak
2015/03/12 12:33:18
Done.
| |
102 net::URLRequest* request, | 103 net::URLRequest* request, |
103 ResourceResponse* response, | 104 ResourceResponse* response, |
104 std::string* payload) override { | 105 std::string* payload) override { |
105 if (stream_has_handler_) { | 106 if (stream_has_handler_) { |
106 intercepted_as_stream_ = true; | 107 intercepted_as_stream_ = true; |
107 return scoped_ptr<ResourceHandler>(new TestResourceHandler).Pass(); | 108 return scoped_ptr<ResourceHandler>(new TestResourceHandler).Pass(); |
108 } else { | 109 } else { |
109 return scoped_ptr<ResourceHandler>(); | 110 return scoped_ptr<ResourceHandler>(); |
110 } | 111 } |
111 } | 112 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 bool defer = false; | 212 bool defer = false; |
212 buffered_handler->OnResponseStarted(response.get(), &defer); | 213 buffered_handler->OnResponseStarted(response.get(), &defer); |
213 | 214 |
214 content::RunAllPendingInMessageLoop(); | 215 content::RunAllPendingInMessageLoop(); |
215 | 216 |
216 return host.intercepted_as_stream(); | 217 return host.intercepted_as_stream(); |
217 } | 218 } |
218 | 219 |
219 // Test that stream requests are correctly intercepted under the right | 220 // Test that stream requests are correctly intercepted under the right |
220 // circumstances. | 221 // circumstances. |
221 TEST_F(BufferedResourceHandlerTest, StreamHandling) { | 222 TEST_F(BufferedResourceHandlerTest, StreamHandling) { |
raymes
2015/03/12 05:21:03
Does this test pass now? I would have expected thi
Deepak
2015/03/12 12:33:18
I have run all content_unittests, All the test cas
| |
222 bool allow_download; | 223 bool allow_download; |
223 bool must_download; | 224 bool must_download; |
224 ResourceType resource_type; | 225 ResourceType resource_type; |
225 | 226 |
226 // Ensure the stream is handled by MaybeInterceptAsStream in the | 227 // Ensure the stream is handled by MaybeInterceptAsStream in the |
227 // ResourceDispatcherHost. | 228 // ResourceDispatcherHost. |
228 set_stream_has_handler(true); | 229 set_stream_has_handler(true); |
229 | 230 |
230 // Main frame request with no download allowed. Stream shouldn't be | 231 // Main frame request with no download allowed. Stream shouldn't be |
231 // intercepted. | 232 // intercepted. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 allow_download = true; | 278 allow_download = true; |
278 must_download = false; | 279 must_download = false; |
279 resource_type = RESOURCE_TYPE_MAIN_FRAME; | 280 resource_type = RESOURCE_TYPE_MAIN_FRAME; |
280 EXPECT_FALSE( | 281 EXPECT_FALSE( |
281 TestStreamIsIntercepted(allow_download, must_download, resource_type)); | 282 TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
282 } | 283 } |
283 | 284 |
284 } // namespace | 285 } // namespace |
285 | 286 |
286 } // namespace content | 287 } // namespace content |
OLD | NEW |