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

Side by Side Diff: net/ocsp/nss_ocsp.cc

Issue 669813003: Update from chromium https://crrev.com/301725/ (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « net/net_unittests.isolate ('k') | net/ocsp/nss_ocsp_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/ocsp/nss_ocsp.h" 5 #include "net/ocsp/nss_ocsp.h"
6 6
7 #include <certt.h> 7 #include <certt.h>
8 #include <certdb.h> 8 #include <certdb.h>
9 #include <ocsp.h> 9 #include <ocsp.h>
10 #include <nspr.h> 10 #include <nspr.h>
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 const std::string& http_response_headers() const { 276 const std::string& http_response_headers() const {
277 DCHECK(finished_); 277 DCHECK(finished_);
278 return response_headers_->raw_headers(); 278 return response_headers_->raw_headers();
279 } 279 }
280 280
281 const std::string& http_response_data() const { 281 const std::string& http_response_data() const {
282 DCHECK(finished_); 282 DCHECK(finished_);
283 return data_; 283 return data_;
284 } 284 }
285 285
286 virtual void OnReceivedRedirect(URLRequest* request, 286 void OnReceivedRedirect(URLRequest* request,
287 const RedirectInfo& redirect_info, 287 const RedirectInfo& redirect_info,
288 bool* defer_redirect) override { 288 bool* defer_redirect) override {
289 DCHECK_EQ(request_.get(), request); 289 DCHECK_EQ(request_.get(), request);
290 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); 290 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_);
291 291
292 if (!redirect_info.new_url.SchemeIs("http")) { 292 if (!redirect_info.new_url.SchemeIs("http")) {
293 // Prevent redirects to non-HTTP schemes, including HTTPS. This matches 293 // Prevent redirects to non-HTTP schemes, including HTTPS. This matches
294 // the initial check in OCSPServerSession::CreateRequest(). 294 // the initial check in OCSPServerSession::CreateRequest().
295 CancelURLRequest(); 295 CancelURLRequest();
296 } 296 }
297 } 297 }
298 298
299 virtual void OnResponseStarted(URLRequest* request) override { 299 void OnResponseStarted(URLRequest* request) override {
300 DCHECK_EQ(request_.get(), request); 300 DCHECK_EQ(request_.get(), request);
301 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); 301 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_);
302 302
303 int bytes_read = 0; 303 int bytes_read = 0;
304 if (request->status().is_success()) { 304 if (request->status().is_success()) {
305 response_code_ = request_->GetResponseCode(); 305 response_code_ = request_->GetResponseCode();
306 response_headers_ = request_->response_headers(); 306 response_headers_ = request_->response_headers();
307 response_headers_->GetMimeType(&response_content_type_); 307 response_headers_->GetMimeType(&response_content_type_);
308 request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read); 308 request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read);
309 } 309 }
310 OnReadCompleted(request_.get(), bytes_read); 310 OnReadCompleted(request_.get(), bytes_read);
311 } 311 }
312 312
313 virtual void OnReadCompleted(URLRequest* request, 313 void OnReadCompleted(URLRequest* request, int bytes_read) override {
314 int bytes_read) override {
315 DCHECK_EQ(request_.get(), request); 314 DCHECK_EQ(request_.get(), request);
316 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); 315 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_);
317 316
318 do { 317 do {
319 if (!request_->status().is_success() || bytes_read <= 0) 318 if (!request_->status().is_success() || bytes_read <= 0)
320 break; 319 break;
321 data_.append(buffer_->data(), bytes_read); 320 data_.append(buffer_->data(), bytes_read);
322 } while (request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read)); 321 } while (request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read));
323 322
324 if (!request_->status().is_io_pending()) { 323 if (!request_->status().is_io_pending()) {
(...skipping 27 matching lines...) Expand all
352 io_loop_ = NULL; 351 io_loop_ = NULL;
353 } 352 }
354 cv_.Signal(); 353 cv_.Signal();
355 Release(); // Balanced with StartURLRequest(). 354 Release(); // Balanced with StartURLRequest().
356 } 355 }
357 } 356 }
358 357
359 private: 358 private:
360 friend class base::RefCountedThreadSafe<OCSPRequestSession>; 359 friend class base::RefCountedThreadSafe<OCSPRequestSession>;
361 360
362 virtual ~OCSPRequestSession() { 361 ~OCSPRequestSession() override {
363 // When this destructor is called, there should be only one thread that has 362 // When this destructor is called, there should be only one thread that has
364 // a reference to this object, and so that thread doesn't need to lock 363 // a reference to this object, and so that thread doesn't need to lock
365 // |lock_| here. 364 // |lock_| here.
366 DCHECK(!request_); 365 DCHECK(!request_);
367 DCHECK(!io_loop_); 366 DCHECK(!io_loop_);
368 } 367 }
369 368
370 // Must call this method while holding |lock_|. 369 // Must call this method while holding |lock_|.
371 void CancelLocked() { 370 void CancelLocked() {
372 lock_.AssertAcquired(); 371 lock_.AssertAcquired();
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { 967 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) {
969 pthread_mutex_lock(&g_request_context_lock); 968 pthread_mutex_lock(&g_request_context_lock);
970 if (request_context) { 969 if (request_context) {
971 DCHECK(!g_request_context); 970 DCHECK(!g_request_context);
972 } 971 }
973 g_request_context = request_context; 972 g_request_context = request_context;
974 pthread_mutex_unlock(&g_request_context_lock); 973 pthread_mutex_unlock(&g_request_context_lock);
975 } 974 }
976 975
977 } // namespace net 976 } // namespace net
OLDNEW
« no previous file with comments | « net/net_unittests.isolate ('k') | net/ocsp/nss_ocsp_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698