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

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 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
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 do {
321 if (!request_->status().is_success() || bytes_read <= 0) 322 if (bytes_read <= 0)
322 break; 323 break;
323 data_.append(buffer_->data(), bytes_read); 324 data_.append(buffer_->data(), bytes_read);
324 } while (request_->Read(buffer_.get(), kRecvBufferSize, &bytes_read)); 325 bytes_read = request_->Read(buffer_.get(), kRecvBufferSize);
326 } while (bytes_read > 0);
mmenke 2016/08/30 22:13:22 This final while condition is no longer needed. T
maksims (do not use this acc) 2016/09/01 12:22:29 Done!
325 327
326 if (!request_->status().is_io_pending()) { 328 if (bytes_read != ERR_IO_PENDING) {
327 request_.reset(); 329 request_.reset();
328 g_ocsp_io_loop.Get().RemoveRequest(this); 330 g_ocsp_io_loop.Get().RemoveRequest(this);
329 { 331 {
330 base::AutoLock autolock(lock_); 332 base::AutoLock autolock(lock_);
331 finished_ = true; 333 finished_ = true;
332 io_loop_ = NULL; 334 io_loop_ = NULL;
333 } 335 }
334 cv_.Signal(); 336 cv_.Signal();
335 Release(); // Balanced with StartURLRequest(). 337 Release(); // Balanced with StartURLRequest().
336 } 338 }
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { 966 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) {
965 pthread_mutex_lock(&g_request_context_lock); 967 pthread_mutex_lock(&g_request_context_lock);
966 if (request_context) { 968 if (request_context) {
967 DCHECK(!g_request_context); 969 DCHECK(!g_request_context);
968 } 970 }
969 g_request_context = request_context; 971 g_request_context = request_context;
970 pthread_mutex_unlock(&g_request_context_lock); 972 pthread_mutex_unlock(&g_request_context_lock);
971 } 973 }
972 974
973 } // namespace net 975 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698