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

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

Issue 2848313003: Revert of Remove client_certs from SSLCertRequestInfo. (Closed)
Patch Set: Created 3 years, 7 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 9
10 #include <deque> 10 #include <deque>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 requested_authorities_(requested_authorities), 83 requested_authorities_(requested_authorities),
84 request_count_(request_count) { 84 request_count_(request_count) {
85 requested_authorities_->clear(); 85 requested_authorities_->clear();
86 *request_count_ = 0; 86 *request_count_ = 0;
87 } 87 }
88 88
89 ~ClientCertStoreStub() override {} 89 ~ClientCertStoreStub() override {}
90 90
91 // net::ClientCertStore: 91 // net::ClientCertStore:
92 void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info, 92 void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info,
93 const ClientCertListCallback& callback) override { 93 net::CertificateList* selected_certs,
94 const base::Closure& callback) override {
94 *requested_authorities_ = cert_request_info.cert_authorities; 95 *requested_authorities_ = cert_request_info.cert_authorities;
95 ++(*request_count_); 96 ++(*request_count_);
96 97
97 callback.Run(response_); 98 *selected_certs = response_;
99 callback.Run();
98 } 100 }
99 101
100 private: 102 private:
101 const net::CertificateList response_; 103 const net::CertificateList response_;
102 std::vector<std::string>* requested_authorities_; 104 std::vector<std::string>* requested_authorities_;
103 int* request_count_; 105 int* request_count_;
104 }; 106 };
105 107
106 // Client certificate store which destroys its resource loader before the 108 // Client certificate store which destroys its resource loader before the
107 // asynchronous GetClientCerts callback is called. 109 // asynchronous GetClientCerts callback is called.
108 class LoaderDestroyingCertStore : public net::ClientCertStore { 110 class LoaderDestroyingCertStore : public net::ClientCertStore {
109 public: 111 public:
110 // Creates a client certificate store which, when looked up, posts a task to 112 // Creates a client certificate store which, when looked up, posts a task to
111 // reset |loader| and then call the callback. The caller is responsible for 113 // reset |loader| and then call the callback. The caller is responsible for
112 // ensuring the pointers remain valid until the process is complete. 114 // ensuring the pointers remain valid until the process is complete.
113 LoaderDestroyingCertStore(std::unique_ptr<ResourceLoader>* loader, 115 LoaderDestroyingCertStore(std::unique_ptr<ResourceLoader>* loader,
114 const base::Closure& on_loader_deleted_callback) 116 const base::Closure& on_loader_deleted_callback)
115 : loader_(loader), 117 : loader_(loader),
116 on_loader_deleted_callback_(on_loader_deleted_callback) {} 118 on_loader_deleted_callback_(on_loader_deleted_callback) {}
117 119
118 // net::ClientCertStore: 120 // net::ClientCertStore:
119 void GetClientCerts( 121 void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info,
120 const net::SSLCertRequestInfo& cert_request_info, 122 net::CertificateList* selected_certs,
121 const ClientCertListCallback& cert_selected_callback) override { 123 const base::Closure& cert_selected_callback) override {
122 // Don't destroy |loader_| while it's on the stack. 124 // Don't destroy |loader_| while it's on the stack.
123 base::ThreadTaskRunnerHandle::Get()->PostTask( 125 base::ThreadTaskRunnerHandle::Get()->PostTask(
124 FROM_HERE, base::Bind(&LoaderDestroyingCertStore::DoCallback, 126 FROM_HERE, base::Bind(&LoaderDestroyingCertStore::DoCallback,
125 base::Unretained(loader_), cert_selected_callback, 127 base::Unretained(loader_),
128 cert_selected_callback,
126 on_loader_deleted_callback_)); 129 on_loader_deleted_callback_));
127 } 130 }
128 131
129 private: 132 private:
130 // This needs to be static because |loader| owns the 133 // This needs to be static because |loader| owns the
131 // LoaderDestroyingCertStore (ClientCertStores are actually handles, and not 134 // LoaderDestroyingCertStore (ClientCertStores are actually handles, and not
132 // global cert stores). 135 // global cert stores).
133 static void DoCallback(std::unique_ptr<ResourceLoader>* loader, 136 static void DoCallback(std::unique_ptr<ResourceLoader>* loader,
134 const ClientCertListCallback& cert_selected_callback, 137 const base::Closure& cert_selected_callback,
135 const base::Closure& on_loader_deleted_callback) { 138 const base::Closure& on_loader_deleted_callback) {
136 loader->reset(); 139 loader->reset();
137 cert_selected_callback.Run(net::CertificateList()); 140 cert_selected_callback.Run();
138 on_loader_deleted_callback.Run(); 141 on_loader_deleted_callback.Run();
139 } 142 }
140 143
141 std::unique_ptr<ResourceLoader>* loader_; 144 std::unique_ptr<ResourceLoader>* loader_;
142 base::Closure on_loader_deleted_callback_; 145 base::Closure on_loader_deleted_callback_;
143 146
144 DISALLOW_COPY_AND_ASSIGN(LoaderDestroyingCertStore); 147 DISALLOW_COPY_AND_ASSIGN(LoaderDestroyingCertStore);
145 }; 148 };
146 149
147 // A mock URLRequestJob which simulates an SSL client auth request. 150 // A mock URLRequestJob which simulates an SSL client auth request.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 void WaitForSelectCertificate() { 273 void WaitForSelectCertificate() {
271 select_certificate_run_loop_.Run(); 274 select_certificate_run_loop_.Run();
272 // Process any pending messages - just so tests can check if 275 // Process any pending messages - just so tests can check if
273 // SelectClientCertificate was called more than once. 276 // SelectClientCertificate was called more than once.
274 base::RunLoop().RunUntilIdle(); 277 base::RunLoop().RunUntilIdle();
275 } 278 }
276 279
277 void SelectClientCertificate( 280 void SelectClientCertificate(
278 WebContents* web_contents, 281 WebContents* web_contents,
279 net::SSLCertRequestInfo* cert_request_info, 282 net::SSLCertRequestInfo* cert_request_info,
280 net::CertificateList client_certs,
281 std::unique_ptr<ClientCertificateDelegate> delegate) override { 283 std::unique_ptr<ClientCertificateDelegate> delegate) override {
282 EXPECT_FALSE(delegate_.get()); 284 EXPECT_FALSE(delegate_.get());
283 285
284 ++call_count_; 286 ++call_count_;
285 passed_certs_ = std::move(client_certs); 287 passed_certs_ = cert_request_info->client_certs;
286 delegate_ = std::move(delegate); 288 delegate_ = std::move(delegate);
287 select_certificate_run_loop_.Quit(); 289 select_certificate_run_loop_.Quit();
288 } 290 }
289 291
290 int call_count() { return call_count_; } 292 int call_count() { return call_count_; }
291 net::CertificateList passed_certs() { return passed_certs_; } 293 net::CertificateList passed_certs() { return passed_certs_; }
292 294
293 void ContinueWithCertificate(net::X509Certificate* cert) { 295 void ContinueWithCertificate(net::X509Certificate* cert) {
294 delegate_->ContinueWithCertificate(cert); 296 delegate_->ContinueWithCertificate(cert);
295 delegate_.reset(); 297 delegate_.reset();
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 1559
1558 // Tests that the effective connection type is not set on non-main frame 1560 // Tests that the effective connection type is not set on non-main frame
1559 // requests. 1561 // requests.
1560 TEST_F(EffectiveConnectionTypeResourceLoaderTest, DoesNotBelongToMainFrame) { 1562 TEST_F(EffectiveConnectionTypeResourceLoaderTest, DoesNotBelongToMainFrame) {
1561 VerifyEffectiveConnectionType(RESOURCE_TYPE_OBJECT, false, 1563 VerifyEffectiveConnectionType(RESOURCE_TYPE_OBJECT, false,
1562 net::EFFECTIVE_CONNECTION_TYPE_3G, 1564 net::EFFECTIVE_CONNECTION_TYPE_3G,
1563 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN); 1565 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN);
1564 } 1566 }
1565 1567
1566 } // namespace content 1568 } // namespace content
OLDNEW
« no previous file with comments | « chromecast/browser/cast_content_browser_client.cc ('k') | content/browser/ssl/ssl_client_auth_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698