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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 public: | 250 public: |
251 explicit TestFilterSpecifyingChild(ResourceContext* resource_context, | 251 explicit TestFilterSpecifyingChild(ResourceContext* resource_context, |
252 int process_id) | 252 int process_id) |
253 : ResourceMessageFilter( | 253 : ResourceMessageFilter( |
254 process_id, | 254 process_id, |
255 NULL, | 255 NULL, |
256 NULL, | 256 NULL, |
257 NULL, | 257 NULL, |
258 NULL, | 258 NULL, |
259 base::Bind(&TestFilterSpecifyingChild::GetContexts, | 259 base::Bind(&TestFilterSpecifyingChild::GetContexts, |
260 base::Unretained(this))), | 260 base::Unretained(this)), |
| 261 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
| 262 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)), |
261 resource_context_(resource_context), | 263 resource_context_(resource_context), |
262 canceled_(false), | 264 canceled_(false), |
263 received_after_canceled_(0) { | 265 received_after_canceled_(0) { |
264 InitializeForTest(); | 266 InitializeForTest(); |
265 set_peer_process_for_testing(base::Process::Current()); | 267 set_peer_process_for_testing(base::Process::Current()); |
266 } | 268 } |
267 | 269 |
268 void set_canceled(bool canceled) { canceled_ = canceled; } | 270 void set_canceled(bool canceled) { canceled_ = canceled; } |
269 int received_after_canceled() const { return received_after_canceled_; } | 271 int received_after_canceled() const { return received_after_canceled_; } |
270 | 272 |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 } | 843 } |
842 | 844 |
843 class ResourceDispatcherHostTest : public testing::Test, public IPC::Sender { | 845 class ResourceDispatcherHostTest : public testing::Test, public IPC::Sender { |
844 public: | 846 public: |
845 typedef ResourceDispatcherHostImpl::LoadInfo LoadInfo; | 847 typedef ResourceDispatcherHostImpl::LoadInfo LoadInfo; |
846 typedef ResourceDispatcherHostImpl::LoadInfoList LoadInfoList; | 848 typedef ResourceDispatcherHostImpl::LoadInfoList LoadInfoList; |
847 typedef ResourceDispatcherHostImpl::LoadInfoMap LoadInfoMap; | 849 typedef ResourceDispatcherHostImpl::LoadInfoMap LoadInfoMap; |
848 | 850 |
849 ResourceDispatcherHostTest() | 851 ResourceDispatcherHostTest() |
850 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 852 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
851 host_(base::Bind(&DownloadResourceHandler::Create)), | 853 host_(base::Bind(&DownloadResourceHandler::Create), |
| 854 base::ThreadTaskRunnerHandle::Get(), |
| 855 base::ThreadTaskRunnerHandle::Get()), |
852 use_test_ssl_certificate_(false), | 856 use_test_ssl_certificate_(false), |
853 send_data_received_acks_(false), | 857 send_data_received_acks_(false), |
854 auto_advance_(false) { | 858 auto_advance_(false) { |
855 host_.SetLoaderDelegate(&loader_delegate_); | 859 host_.SetLoaderDelegate(&loader_delegate_); |
856 browser_context_.reset(new TestBrowserContext()); | 860 browser_context_.reset(new TestBrowserContext()); |
857 BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); | 861 BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); |
858 base::RunLoop().RunUntilIdle(); | 862 base::RunLoop().RunUntilIdle(); |
859 filter_ = MakeForwardingFilter(); | 863 filter_ = MakeForwardingFilter(); |
860 // TODO(cbentzel): Better way to get URLRequestContext? | 864 // TODO(cbentzel): Better way to get URLRequestContext? |
861 net::URLRequestContext* request_context = | 865 net::URLRequestContext* request_context = |
862 browser_context_->GetResourceContext()->GetRequestContext(); | 866 browser_context_->GetResourceContext()->GetRequestContext(); |
863 job_factory_.reset(new TestURLRequestJobFactory(this)); | 867 job_factory_.reset(new TestURLRequestJobFactory(this)); |
864 request_context->set_job_factory(job_factory_.get()); | 868 request_context->set_job_factory(job_factory_.get()); |
865 request_context->set_network_delegate(&network_delegate_); | 869 request_context->set_network_delegate(&network_delegate_); |
866 } | 870 } |
867 | 871 |
868 ~ResourceDispatcherHostTest() override { | 872 ~ResourceDispatcherHostTest() override { |
869 filter_->OnChannelClosing(); | 873 filter_->OnChannelClosing(); |
| 874 filter_ = nullptr; |
| 875 web_contents_filter_ = nullptr; |
870 } | 876 } |
871 | 877 |
872 // IPC::Sender implementation | 878 // IPC::Sender implementation |
873 bool Send(IPC::Message* msg) override { | 879 bool Send(IPC::Message* msg) override { |
874 accum_.AddMessage(*msg); | 880 accum_.AddMessage(*msg); |
875 | 881 |
876 if (send_data_received_acks_ && | 882 if (send_data_received_acks_ && |
877 msg->type() == ResourceMsg_DataReceived::ID) { | 883 msg->type() == ResourceMsg_DataReceived::ID) { |
878 GenerateDataReceivedACK(*msg); | 884 GenerateDataReceivedACK(*msg); |
879 } | 885 } |
(...skipping 3044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3924 return nullptr; | 3930 return nullptr; |
3925 } | 3931 } |
3926 | 3932 |
3927 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse( | 3933 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse( |
3928 net::URLRequest* request, | 3934 net::URLRequest* request, |
3929 net::NetworkDelegate* network_delegate) const { | 3935 net::NetworkDelegate* network_delegate) const { |
3930 return nullptr; | 3936 return nullptr; |
3931 } | 3937 } |
3932 | 3938 |
3933 } // namespace content | 3939 } // namespace content |
OLD | NEW |