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

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

Issue 1815363002: Add RetainedRef uses where needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 // net::URLRequestTestJob: 162 // net::URLRequestTestJob:
163 void Start() override { 163 void Start() override {
164 scoped_refptr<net::SSLCertRequestInfo> cert_request_info( 164 scoped_refptr<net::SSLCertRequestInfo> cert_request_info(
165 new net::SSLCertRequestInfo); 165 new net::SSLCertRequestInfo);
166 cert_request_info->cert_authorities = test_authorities(); 166 cert_request_info->cert_authorities = test_authorities();
167 base::ThreadTaskRunnerHandle::Get()->PostTask( 167 base::ThreadTaskRunnerHandle::Get()->PostTask(
168 FROM_HERE, 168 FROM_HERE,
169 base::Bind(&MockClientCertURLRequestJob::NotifyCertificateRequested, 169 base::Bind(&MockClientCertURLRequestJob::NotifyCertificateRequested,
170 weak_factory_.GetWeakPtr(), cert_request_info)); 170 weak_factory_.GetWeakPtr(),
171 base::RetainedRef(cert_request_info)));
171 } 172 }
172 173
173 void ContinueWithCertificate(net::X509Certificate* cert, 174 void ContinueWithCertificate(net::X509Certificate* cert,
174 net::SSLPrivateKey* private_key) override { 175 net::SSLPrivateKey* private_key) override {
175 net::URLRequestTestJob::Start(); 176 net::URLRequestTestJob::Start();
176 } 177 }
177 178
178 private: 179 private:
179 ~MockClientCertURLRequestJob() override {} 180 ~MockClientCertURLRequestJob() override {}
180 181
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 DISALLOW_COPY_AND_ASSIGN(NonChunkedUploadDataStream); 526 DISALLOW_COPY_AND_ASSIGN(NonChunkedUploadDataStream);
526 }; 527 };
527 528
528 // Fails to create a temporary file with the given error. 529 // Fails to create a temporary file with the given error.
529 void CreateTemporaryError( 530 void CreateTemporaryError(
530 base::File::Error error, 531 base::File::Error error,
531 const CreateTemporaryFileStreamCallback& callback) { 532 const CreateTemporaryFileStreamCallback& callback) {
532 base::ThreadTaskRunnerHandle::Get()->PostTask( 533 base::ThreadTaskRunnerHandle::Get()->PostTask(
533 FROM_HERE, 534 FROM_HERE,
534 base::Bind(callback, error, base::Passed(scoped_ptr<net::FileStream>()), 535 base::Bind(callback, error, base::Passed(scoped_ptr<net::FileStream>()),
535 scoped_refptr<ShareableFileReference>())); 536 nullptr));
536 } 537 }
537 538
538 } // namespace 539 } // namespace
539 540
540 class ResourceLoaderTest : public testing::Test, 541 class ResourceLoaderTest : public testing::Test,
541 public ResourceLoaderDelegate { 542 public ResourceLoaderDelegate {
542 protected: 543 protected:
543 ResourceLoaderTest() 544 ResourceLoaderTest()
544 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 545 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
545 resource_context_(&test_url_request_context_), 546 resource_context_(&test_url_request_context_),
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 base::Unretained(this), 913 base::Unretained(this),
913 base::Passed(&file_stream))); 914 base::Passed(&file_stream)));
914 return std::move(handler); 915 return std::move(handler);
915 } 916 }
916 917
917 private: 918 private:
918 void PostCallback( 919 void PostCallback(
919 scoped_ptr<net::FileStream> file_stream, 920 scoped_ptr<net::FileStream> file_stream,
920 const CreateTemporaryFileStreamCallback& callback) { 921 const CreateTemporaryFileStreamCallback& callback) {
921 base::ThreadTaskRunnerHandle::Get()->PostTask( 922 base::ThreadTaskRunnerHandle::Get()->PostTask(
922 FROM_HERE, base::Bind(callback, base::File::FILE_OK, 923 FROM_HERE,
923 base::Passed(&file_stream), deletable_file_)); 924 base::Bind(callback, base::File::FILE_OK, base::Passed(&file_stream),
925 base::RetainedRef(deletable_file_)));
924 } 926 }
925 927
926 base::FilePath temp_path_; 928 base::FilePath temp_path_;
927 scoped_refptr<ShareableFileReference> deletable_file_; 929 scoped_refptr<ShareableFileReference> deletable_file_;
928 // These are owned by the ResourceLoader. 930 // These are owned by the ResourceLoader.
929 net::testing::MockFileStream* file_stream_; 931 net::testing::MockFileStream* file_stream_;
930 RedirectToFileResourceHandler* redirect_to_file_resource_handler_; 932 RedirectToFileResourceHandler* redirect_to_file_resource_handler_;
931 }; 933 };
932 934
933 // Tests that a RedirectToFileResourceHandler works and forwards everything 935 // Tests that a RedirectToFileResourceHandler works and forwards everything
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 ASSERT_TRUE( 1149 ASSERT_TRUE(
1148 CertStore::GetInstance()->RetrieveCert(deserialized.cert_id, &cert)); 1150 CertStore::GetInstance()->RetrieveCert(deserialized.cert_id, &cert));
1149 EXPECT_TRUE(cert->Equals(GetTestCert().get())); 1151 EXPECT_TRUE(cert->Equals(GetTestCert().get()));
1150 1152
1151 EXPECT_EQ(kTestCertError, deserialized.cert_status); 1153 EXPECT_EQ(kTestCertError, deserialized.cert_status);
1152 EXPECT_EQ(kTestConnectionStatus, deserialized.connection_status); 1154 EXPECT_EQ(kTestConnectionStatus, deserialized.connection_status);
1153 EXPECT_EQ(kTestSecurityBits, deserialized.security_bits); 1155 EXPECT_EQ(kTestSecurityBits, deserialized.security_bits);
1154 } 1156 }
1155 1157
1156 } // namespace content 1158 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698