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

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

Issue 2265873002: Adjust callers and networking delegates in net/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: rebased on top of URLRequest::Read CL Created 4 years, 3 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
« no previous file with comments | « net/cert_net/cert_net_fetcher_impl.cc ('k') | net/nqe/network_quality_estimator.h » ('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/cert_net/nss_ocsp.h" 5 #include "net/cert_net/nss_ocsp.h"
6 6
7 #include <certt.h> 7 #include <certt.h>
8 #include <certdb.h> 8 #include <certdb.h>
9 #include <nspr.h> 9 #include <nspr.h>
10 #include <nss.h> 10 #include <nss.h>
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 DCHECK_EQ(request_.get(), request); 292 DCHECK_EQ(request_.get(), request);
293 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); 293 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_);
294 294
295 if (!redirect_info.new_url.SchemeIs("http")) { 295 if (!redirect_info.new_url.SchemeIs("http")) {
296 // Prevent redirects to non-HTTP schemes, including HTTPS. This matches 296 // Prevent redirects to non-HTTP schemes, including HTTPS. This matches
297 // the initial check in OCSPServerSession::CreateRequest(). 297 // the initial check in OCSPServerSession::CreateRequest().
298 CancelURLRequest(); 298 CancelURLRequest();
299 } 299 }
300 } 300 }
301 301
302 void OnResponseStarted(URLRequest* request) override { 302 void OnResponseStarted(URLRequest* request, int net_error) override {
303 DCHECK_EQ(request_.get(), request); 303 DCHECK_EQ(request_.get(), request);
304 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); 304 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_);
305 DCHECK_NE(ERR_IO_PENDING, net_error);
305 306
306 int bytes_read = 0; 307 int bytes_read = 0;
307 if (request->status().is_success()) { 308 if (net_error == OK) {
308 response_code_ = request_->GetResponseCode(); 309 response_code_ = request_->GetResponseCode();
309 response_headers_ = request_->response_headers(); 310 response_headers_ = request_->response_headers();
310 response_headers_->GetMimeType(&response_content_type_); 311 response_headers_->GetMimeType(&response_content_type_);
311 request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read); 312 bytes_read = request_->Read(buffer_.get(), kRecvBufferSize);
312 } 313 }
313 OnReadCompleted(request_.get(), bytes_read); 314 OnReadCompleted(request_.get(), bytes_read);
314 } 315 }
315 316
316 void OnReadCompleted(URLRequest* request, int bytes_read) override { 317 void OnReadCompleted(URLRequest* request, int bytes_read) override {
317 DCHECK_EQ(request_.get(), request); 318 DCHECK_EQ(request_.get(), request);
318 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_); 319 DCHECK_EQ(base::MessageLoopForIO::current(), io_loop_);
319 320
320 do { 321 while (bytes_read > 0) {
321 if (!request_->status().is_success() || bytes_read <= 0)
322 break;
323 data_.append(buffer_->data(), bytes_read); 322 data_.append(buffer_->data(), bytes_read);
324 } while (request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read)); 323 bytes_read = request_->Read(buffer_.get(), kRecvBufferSize);
324 }
325 325
326 if (!request_->status().is_io_pending()) { 326 if (bytes_read != ERR_IO_PENDING) {
327 request_.reset(); 327 request_.reset();
328 g_ocsp_io_loop.Get().RemoveRequest(this); 328 g_ocsp_io_loop.Get().RemoveRequest(this);
329 { 329 {
330 base::AutoLock autolock(lock_); 330 base::AutoLock autolock(lock_);
331 finished_ = true; 331 finished_ = true;
332 io_loop_ = NULL; 332 io_loop_ = NULL;
333 } 333 }
334 cv_.Signal(); 334 cv_.Signal();
335 Release(); // Balanced with StartURLRequest(). 335 Release(); // Balanced with StartURLRequest().
336 } 336 }
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { 964 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) {
965 pthread_mutex_lock(&g_request_context_lock); 965 pthread_mutex_lock(&g_request_context_lock);
966 if (request_context) { 966 if (request_context) {
967 DCHECK(!g_request_context); 967 DCHECK(!g_request_context);
968 } 968 }
969 g_request_context = request_context; 969 g_request_context = request_context;
970 pthread_mutex_unlock(&g_request_context_lock); 970 pthread_mutex_unlock(&g_request_context_lock);
971 } 971 }
972 972
973 } // namespace net 973 } // namespace net
OLDNEW
« no previous file with comments | « net/cert_net/cert_net_fetcher_impl.cc ('k') | net/nqe/network_quality_estimator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698