| 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 #include "android_webview/browser/input_stream.h" | 5 #include "android_webview/browser/input_stream.h" |
| 6 #include "android_webview/browser/net/android_stream_reader_url_request_job.h" | 6 #include "android_webview/browser/net/android_stream_reader_url_request_job.h" |
| 7 #include "android_webview/browser/net/aw_url_request_job_factory.h" | 7 #include "android_webview/browser/net/aw_url_request_job_factory.h" |
| 8 #include "android_webview/browser/net/input_stream_reader.h" | 8 #include "android_webview/browser/net/input_stream_reader.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 stream_reader_delegate) { | 211 stream_reader_delegate) { |
| 212 TestStreamReaderJob* test_stream_reader_job = | 212 TestStreamReaderJob* test_stream_reader_job = |
| 213 new TestStreamReaderJob( | 213 new TestStreamReaderJob( |
| 214 req_.get(), | 214 req_.get(), |
| 215 &network_delegate_, | 215 &network_delegate_, |
| 216 stream_reader_delegate.Pass(), | 216 stream_reader_delegate.Pass(), |
| 217 stream_reader.Pass()); | 217 stream_reader.Pass()); |
| 218 // The Interceptor is owned by the |factory_|. | 218 // The Interceptor is owned by the |factory_|. |
| 219 TestJobInterceptor* protocol_handler = new TestJobInterceptor; | 219 TestJobInterceptor* protocol_handler = new TestJobInterceptor; |
| 220 protocol_handler->set_main_intercept_job(test_stream_reader_job); | 220 protocol_handler->set_main_intercept_job(test_stream_reader_job); |
| 221 bool set_protocol = factory_.SetProtocolHandler("http", protocol_handler); | 221 bool set_protocol = |
| 222 factory_.SetProtocolHandler("http", make_scoped_ptr(protocol_handler)); |
| 222 DCHECK(set_protocol); | 223 DCHECK(set_protocol); |
| 223 | 224 |
| 224 protocol_handler = new TestJobInterceptor; | 225 protocol_handler = new TestJobInterceptor; |
| 225 protocol_handler->set_main_intercept_job(test_stream_reader_job); | 226 protocol_handler->set_main_intercept_job(test_stream_reader_job); |
| 226 set_protocol = factory_.SetProtocolHandler("content", protocol_handler); | 227 set_protocol = factory_.SetProtocolHandler( |
| 228 "content", make_scoped_ptr(protocol_handler)); |
| 227 DCHECK(set_protocol); | 229 DCHECK(set_protocol); |
| 228 } | 230 } |
| 229 | 231 |
| 230 base::MessageLoopForIO loop_; | 232 base::MessageLoopForIO loop_; |
| 231 TestURLRequestContext context_; | 233 TestURLRequestContext context_; |
| 232 android_webview::AwURLRequestJobFactory factory_; | 234 android_webview::AwURLRequestJobFactory factory_; |
| 233 TestDelegate url_request_delegate_; | 235 TestDelegate url_request_delegate_; |
| 234 TestNetworkDelegate network_delegate_; | 236 TestNetworkDelegate network_delegate_; |
| 235 scoped_ptr<URLRequest> req_; | 237 scoped_ptr<URLRequest> req_; |
| 236 }; | 238 }; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 408 |
| 407 SetRange(req_.get(), offset, bytes_available); | 409 SetRange(req_.get(), offset, bytes_available); |
| 408 req_->Start(); | 410 req_->Start(); |
| 409 | 411 |
| 410 loop.Run(); | 412 loop.Run(); |
| 411 | 413 |
| 412 EXPECT_EQ(0, network_delegate_.completed_requests()); | 414 EXPECT_EQ(0, network_delegate_.completed_requests()); |
| 413 req_->Cancel(); | 415 req_->Cancel(); |
| 414 EXPECT_EQ(1, network_delegate_.completed_requests()); | 416 EXPECT_EQ(1, network_delegate_.completed_requests()); |
| 415 } | 417 } |
| OLD | NEW |