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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_unittest.cc

Issue 2785523002: Reduce/remove usage of BrowserThread in content/browser/loader. (Closed)
Patch Set: Remove DCHECK Created 3 years, 8 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
OLDNEW
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
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::IO)),
261 resource_context_(resource_context), 262 resource_context_(resource_context),
262 canceled_(false), 263 canceled_(false),
263 received_after_canceled_(0) { 264 received_after_canceled_(0) {
264 InitializeForTest(); 265 InitializeForTest();
265 set_peer_process_for_testing(base::Process::Current()); 266 set_peer_process_for_testing(base::Process::Current());
266 } 267 }
267 268
268 void set_canceled(bool canceled) { canceled_ = canceled; } 269 void set_canceled(bool canceled) { canceled_ = canceled; }
269 int received_after_canceled() const { return received_after_canceled_; } 270 int received_after_canceled() const { return received_after_canceled_; }
270 271
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 } 842 }
842 843
843 class ResourceDispatcherHostTest : public testing::Test, public IPC::Sender { 844 class ResourceDispatcherHostTest : public testing::Test, public IPC::Sender {
844 public: 845 public:
845 typedef ResourceDispatcherHostImpl::LoadInfo LoadInfo; 846 typedef ResourceDispatcherHostImpl::LoadInfo LoadInfo;
846 typedef ResourceDispatcherHostImpl::LoadInfoList LoadInfoList; 847 typedef ResourceDispatcherHostImpl::LoadInfoList LoadInfoList;
847 typedef ResourceDispatcherHostImpl::LoadInfoMap LoadInfoMap; 848 typedef ResourceDispatcherHostImpl::LoadInfoMap LoadInfoMap;
848 849
849 ResourceDispatcherHostTest() 850 ResourceDispatcherHostTest()
850 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 851 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
851 host_(base::Bind(&DownloadResourceHandler::Create)), 852 host_(base::Bind(&DownloadResourceHandler::Create),
853 base::ThreadTaskRunnerHandle::Get()),
852 use_test_ssl_certificate_(false), 854 use_test_ssl_certificate_(false),
853 send_data_received_acks_(false), 855 send_data_received_acks_(false),
854 auto_advance_(false) { 856 auto_advance_(false) {
855 host_.SetLoaderDelegate(&loader_delegate_); 857 host_.SetLoaderDelegate(&loader_delegate_);
856 browser_context_.reset(new TestBrowserContext()); 858 browser_context_.reset(new TestBrowserContext());
857 BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); 859 BrowserContext::EnsureResourceContextInitialized(browser_context_.get());
858 base::RunLoop().RunUntilIdle(); 860 base::RunLoop().RunUntilIdle();
859 filter_ = MakeForwardingFilter(); 861 filter_ = MakeForwardingFilter();
860 // TODO(cbentzel): Better way to get URLRequestContext? 862 // TODO(cbentzel): Better way to get URLRequestContext?
861 net::URLRequestContext* request_context = 863 net::URLRequestContext* request_context =
862 browser_context_->GetResourceContext()->GetRequestContext(); 864 browser_context_->GetResourceContext()->GetRequestContext();
863 job_factory_.reset(new TestURLRequestJobFactory(this)); 865 job_factory_.reset(new TestURLRequestJobFactory(this));
864 request_context->set_job_factory(job_factory_.get()); 866 request_context->set_job_factory(job_factory_.get());
865 request_context->set_network_delegate(&network_delegate_); 867 request_context->set_network_delegate(&network_delegate_);
866 } 868 }
867 869
868 ~ResourceDispatcherHostTest() override { 870 ~ResourceDispatcherHostTest() override {
869 filter_->OnChannelClosing(); 871 filter_->OnChannelClosing();
872 filter_ = nullptr;
873 web_contents_filter_ = nullptr;
870 } 874 }
871 875
872 // IPC::Sender implementation 876 // IPC::Sender implementation
873 bool Send(IPC::Message* msg) override { 877 bool Send(IPC::Message* msg) override {
874 accum_.AddMessage(*msg); 878 accum_.AddMessage(*msg);
875 879
876 if (send_data_received_acks_ && 880 if (send_data_received_acks_ &&
877 msg->type() == ResourceMsg_DataReceived::ID) { 881 msg->type() == ResourceMsg_DataReceived::ID) {
878 GenerateDataReceivedACK(*msg); 882 GenerateDataReceivedACK(*msg);
879 } 883 }
(...skipping 3044 matching lines...) Expand 10 before | Expand all | Expand 10 after
3924 return nullptr; 3928 return nullptr;
3925 } 3929 }
3926 3930
3927 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse( 3931 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse(
3928 net::URLRequest* request, 3932 net::URLRequest* request,
3929 net::NetworkDelegate* network_delegate) const { 3933 net::NetworkDelegate* network_delegate) const {
3930 return nullptr; 3934 return nullptr;
3931 } 3935 }
3932 3936
3933 } // namespace content 3937 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/browser/loader/resource_hints_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698