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

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

Issue 663563002: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/resource_loader.h" 5 #include "content/browser/loader/resource_loader.h"
6 6
7 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 return net::URLRequestTestJob::test_url_1(); 297 return net::URLRequestTestJob::test_url_1();
298 } 298 }
299 299
300 std::string test_data() const { 300 std::string test_data() const {
301 return net::URLRequestTestJob::test_data_1(); 301 return net::URLRequestTestJob::test_data_1();
302 } 302 }
303 303
304 virtual scoped_ptr<ResourceHandler> WrapResourceHandler( 304 virtual scoped_ptr<ResourceHandler> WrapResourceHandler(
305 scoped_ptr<ResourceHandlerStub> leaf_handler, 305 scoped_ptr<ResourceHandlerStub> leaf_handler,
306 net::URLRequest* request) { 306 net::URLRequest* request) {
307 return leaf_handler.PassAs<ResourceHandler>(); 307 return leaf_handler.Pass();
308 } 308 }
309 309
310 virtual void SetUp() override { 310 virtual void SetUp() override {
311 const int kRenderProcessId = 1; 311 const int kRenderProcessId = 1;
312 const int kRenderViewId = 2; 312 const int kRenderViewId = 2;
313 313
314 scoped_ptr<net::URLRequest> request( 314 scoped_ptr<net::URLRequest> request(
315 resource_context_.GetRequestContext()->CreateRequest( 315 resource_context_.GetRequestContext()->CreateRequest(
316 test_url(), 316 test_url(),
317 net::DEFAULT_PRIORITY, 317 net::DEFAULT_PRIORITY,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // Set up the test client cert store. 370 // Set up the test client cert store.
371 net::CertificateList dummy_certs(1, scoped_refptr<net::X509Certificate>( 371 net::CertificateList dummy_certs(1, scoped_refptr<net::X509Certificate>(
372 new net::X509Certificate("test", "test", base::Time(), base::Time()))); 372 new net::X509Certificate("test", "test", base::Time(), base::Time())));
373 scoped_ptr<ClientCertStoreStub> test_store( 373 scoped_ptr<ClientCertStoreStub> test_store(
374 new ClientCertStoreStub(dummy_certs)); 374 new ClientCertStoreStub(dummy_certs));
375 EXPECT_EQ(0, test_store->request_count()); 375 EXPECT_EQ(0, test_store->request_count());
376 376
377 // Ownership of the |test_store| is about to be turned over to ResourceLoader. 377 // Ownership of the |test_store| is about to be turned over to ResourceLoader.
378 // We need to keep raw pointer copies to access these objects later. 378 // We need to keep raw pointer copies to access these objects later.
379 ClientCertStoreStub* raw_ptr_to_store = test_store.get(); 379 ClientCertStoreStub* raw_ptr_to_store = test_store.get();
380 resource_context_.SetClientCertStore( 380 resource_context_.SetClientCertStore(test_store.Pass());
381 test_store.PassAs<net::ClientCertStore>());
382 381
383 // Prepare a dummy certificate request. 382 // Prepare a dummy certificate request.
384 scoped_refptr<net::SSLCertRequestInfo> cert_request_info( 383 scoped_refptr<net::SSLCertRequestInfo> cert_request_info(
385 new net::SSLCertRequestInfo()); 384 new net::SSLCertRequestInfo());
386 std::vector<std::string> dummy_authority(1, "dummy"); 385 std::vector<std::string> dummy_authority(1, "dummy");
387 cert_request_info->cert_authorities = dummy_authority; 386 cert_request_info->cert_authorities = dummy_authority;
388 387
389 // Plug in test content browser client. 388 // Plug in test content browser client.
390 SelectCertificateBrowserClient test_client; 389 SelectCertificateBrowserClient test_client;
391 ContentBrowserClient* old_client = SetBrowserClientForTesting(&test_client); 390 ContentBrowserClient* old_client = SetBrowserClientForTesting(&test_client);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 base::MessageLoopProxy::current())); 515 base::MessageLoopProxy::current()));
517 file_stream_ = file_stream.get(); 516 file_stream_ = file_stream.get();
518 deletable_file_ = ShareableFileReference::GetOrCreate( 517 deletable_file_ = ShareableFileReference::GetOrCreate(
519 temp_path_, 518 temp_path_,
520 ShareableFileReference::DELETE_ON_FINAL_RELEASE, 519 ShareableFileReference::DELETE_ON_FINAL_RELEASE,
521 BrowserThread::GetMessageLoopProxyForThread( 520 BrowserThread::GetMessageLoopProxyForThread(
522 BrowserThread::FILE).get()); 521 BrowserThread::FILE).get());
523 522
524 // Inject them into the handler. 523 // Inject them into the handler.
525 scoped_ptr<RedirectToFileResourceHandler> handler( 524 scoped_ptr<RedirectToFileResourceHandler> handler(
526 new RedirectToFileResourceHandler( 525 new RedirectToFileResourceHandler(leaf_handler.Pass(), request));
527 leaf_handler.PassAs<ResourceHandler>(), request));
528 redirect_to_file_resource_handler_ = handler.get(); 526 redirect_to_file_resource_handler_ = handler.get();
529 handler->SetCreateTemporaryFileStreamFunctionForTesting( 527 handler->SetCreateTemporaryFileStreamFunctionForTesting(
530 base::Bind(&ResourceLoaderRedirectToFileTest::PostCallback, 528 base::Bind(&ResourceLoaderRedirectToFileTest::PostCallback,
531 base::Unretained(this), 529 base::Unretained(this),
532 base::Passed(file_stream.PassAs<net::FileStream>()))); 530 base::Passed(&file_stream)));
533 return handler.PassAs<ResourceHandler>(); 531 return handler.Pass();
534 } 532 }
535 533
536 private: 534 private:
537 void PostCallback( 535 void PostCallback(
538 scoped_ptr<net::FileStream> file_stream, 536 scoped_ptr<net::FileStream> file_stream,
539 const CreateTemporaryFileStreamCallback& callback) { 537 const CreateTemporaryFileStreamCallback& callback) {
540 base::MessageLoop::current()->PostTask( 538 base::MessageLoop::current()->PostTask(
541 FROM_HERE, 539 FROM_HERE,
542 base::Bind(callback, base::File::FILE_OK, 540 base::Bind(callback, base::File::FILE_OK,
543 base::Passed(&file_stream), deletable_file_)); 541 base::Passed(&file_stream), deletable_file_));
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 ASSERT_TRUE(base::ReadFileToString(temp_path(), &contents)); 719 ASSERT_TRUE(base::ReadFileToString(temp_path(), &contents));
722 EXPECT_EQ(test_data(), contents); 720 EXPECT_EQ(test_data(), contents);
723 721
724 // Release the loader. The file should be gone now. 722 // Release the loader. The file should be gone now.
725 ReleaseLoader(); 723 ReleaseLoader();
726 base::RunLoop().RunUntilIdle(); 724 base::RunLoop().RunUntilIdle();
727 EXPECT_FALSE(base::PathExists(temp_path())); 725 EXPECT_FALSE(base::PathExists(temp_path()));
728 } 726 }
729 727
730 } // namespace content 728 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/browser/loader/resource_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698