| OLD | NEW |
| 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> |
| 11 #include <ocsp.h> | 11 #include <ocsp.h> |
| 12 #include <pthread.h> | 12 #include <pthread.h> |
| 13 #include <secerr.h> | 13 #include <secerr.h> |
| 14 |
| 14 #include <algorithm> | 15 #include <algorithm> |
| 16 #include <memory> |
| 15 #include <string> | 17 #include <string> |
| 16 #include <utility> | 18 #include <utility> |
| 17 | 19 |
| 18 #include "base/callback.h" | 20 #include "base/callback.h" |
| 19 #include "base/compiler_specific.h" | 21 #include "base/compiler_specific.h" |
| 20 #include "base/lazy_instance.h" | 22 #include "base/lazy_instance.h" |
| 21 #include "base/location.h" | 23 #include "base/location.h" |
| 22 #include "base/logging.h" | 24 #include "base/logging.h" |
| 23 #include "base/macros.h" | 25 #include "base/macros.h" |
| 24 #include "base/memory/scoped_ptr.h" | |
| 25 #include "base/metrics/histogram_macros.h" | 26 #include "base/metrics/histogram_macros.h" |
| 26 #include "base/single_thread_task_runner.h" | 27 #include "base/single_thread_task_runner.h" |
| 27 #include "base/stl_util.h" | 28 #include "base/stl_util.h" |
| 28 #include "base/strings/string_util.h" | 29 #include "base/strings/string_util.h" |
| 29 #include "base/strings/stringprintf.h" | 30 #include "base/strings/stringprintf.h" |
| 30 #include "base/synchronization/condition_variable.h" | 31 #include "base/synchronization/condition_variable.h" |
| 31 #include "base/synchronization/lock.h" | 32 #include "base/synchronization/lock.h" |
| 32 #include "base/threading/thread_checker.h" | 33 #include "base/threading/thread_checker.h" |
| 33 #include "base/time/time.h" | 34 #include "base/time/time.h" |
| 34 #include "net/base/elements_upload_data_stream.h" | 35 #include "net/base/elements_upload_data_stream.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 LOAD_DO_NOT_SEND_COOKIES); | 401 LOAD_DO_NOT_SEND_COOKIES); |
| 401 | 402 |
| 402 if (http_request_method_ == "POST") { | 403 if (http_request_method_ == "POST") { |
| 403 DCHECK(!upload_content_.empty()); | 404 DCHECK(!upload_content_.empty()); |
| 404 DCHECK(!upload_content_type_.empty()); | 405 DCHECK(!upload_content_type_.empty()); |
| 405 | 406 |
| 406 request_->set_method("POST"); | 407 request_->set_method("POST"); |
| 407 extra_request_headers_.SetHeader( | 408 extra_request_headers_.SetHeader( |
| 408 HttpRequestHeaders::kContentType, upload_content_type_); | 409 HttpRequestHeaders::kContentType, upload_content_type_); |
| 409 | 410 |
| 410 scoped_ptr<UploadElementReader> reader(new UploadBytesElementReader( | 411 std::unique_ptr<UploadElementReader> reader(new UploadBytesElementReader( |
| 411 upload_content_.data(), upload_content_.size())); | 412 upload_content_.data(), upload_content_.size())); |
| 412 request_->set_upload( | 413 request_->set_upload( |
| 413 ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); | 414 ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); |
| 414 } | 415 } |
| 415 if (!extra_request_headers_.IsEmpty()) | 416 if (!extra_request_headers_.IsEmpty()) |
| 416 request_->SetExtraRequestHeaders(extra_request_headers_); | 417 request_->SetExtraRequestHeaders(extra_request_headers_); |
| 417 | 418 |
| 418 request_->Start(); | 419 request_->Start(); |
| 419 AddRef(); // Release after |request_| deleted. | 420 AddRef(); // Release after |request_| deleted. |
| 420 } | 421 } |
| 421 | 422 |
| 422 GURL url_; // The URL we eventually wound up at | 423 GURL url_; // The URL we eventually wound up at |
| 423 std::string http_request_method_; | 424 std::string http_request_method_; |
| 424 base::TimeDelta timeout_; // The timeout for OCSP | 425 base::TimeDelta timeout_; // The timeout for OCSP |
| 425 scoped_ptr<URLRequest> request_; // The actual request this wraps | 426 std::unique_ptr<URLRequest> request_; // The actual request this wraps |
| 426 scoped_refptr<IOBuffer> buffer_; // Read buffer | 427 scoped_refptr<IOBuffer> buffer_; // Read buffer |
| 427 HttpRequestHeaders extra_request_headers_; | 428 HttpRequestHeaders extra_request_headers_; |
| 428 | 429 |
| 429 // HTTP POST payload. |request_| reads bytes from this. | 430 // HTTP POST payload. |request_| reads bytes from this. |
| 430 std::string upload_content_; | 431 std::string upload_content_; |
| 431 std::string upload_content_type_; // MIME type of POST payload | 432 std::string upload_content_type_; // MIME type of POST payload |
| 432 | 433 |
| 433 int response_code_; // HTTP status code for the request | 434 int response_code_; // HTTP status code for the request |
| 434 std::string response_content_type_; | 435 std::string response_content_type_; |
| 435 scoped_refptr<HttpResponseHeaders> response_headers_; | 436 scoped_refptr<HttpResponseHeaders> response_headers_; |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { | 963 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { |
| 963 pthread_mutex_lock(&g_request_context_lock); | 964 pthread_mutex_lock(&g_request_context_lock); |
| 964 if (request_context) { | 965 if (request_context) { |
| 965 DCHECK(!g_request_context); | 966 DCHECK(!g_request_context); |
| 966 } | 967 } |
| 967 g_request_context = request_context; | 968 g_request_context = request_context; |
| 968 pthread_mutex_unlock(&g_request_context_lock); | 969 pthread_mutex_unlock(&g_request_context_lock); |
| 969 } | 970 } |
| 970 | 971 |
| 971 } // namespace net | 972 } // namespace net |
| OLD | NEW |