Chromium Code Reviews| 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/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 15 matching lines...) Expand all Loading... | |
| 26 #include "base/string_util.h" | 26 #include "base/string_util.h" |
| 27 #include "base/stringprintf.h" | 27 #include "base/stringprintf.h" |
| 28 #include "base/synchronization/condition_variable.h" | 28 #include "base/synchronization/condition_variable.h" |
| 29 #include "base/synchronization/lock.h" | 29 #include "base/synchronization/lock.h" |
| 30 #include "base/threading/thread_checker.h" | 30 #include "base/threading/thread_checker.h" |
| 31 #include "base/time.h" | 31 #include "base/time.h" |
| 32 #include "googleurl/src/gurl.h" | 32 #include "googleurl/src/gurl.h" |
| 33 #include "net/base/host_port_pair.h" | 33 #include "net/base/host_port_pair.h" |
| 34 #include "net/base/io_buffer.h" | 34 #include "net/base/io_buffer.h" |
| 35 #include "net/base/load_flags.h" | 35 #include "net/base/load_flags.h" |
| 36 #include "net/base/upload_data.h" | 36 #include "net/base/upload_bytes_element_reader.h" |
| 37 #include "net/base/upload_data_stream.h" | |
| 37 #include "net/http/http_request_headers.h" | 38 #include "net/http/http_request_headers.h" |
| 38 #include "net/http/http_response_headers.h" | 39 #include "net/http/http_response_headers.h" |
| 39 #include "net/url_request/url_request.h" | 40 #include "net/url_request/url_request.h" |
| 40 #include "net/url_request/url_request_context.h" | 41 #include "net/url_request/url_request_context.h" |
| 41 | 42 |
| 42 namespace net { | 43 namespace net { |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 46 // Protects |g_request_context|. | 47 // Protects |g_request_context|. |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 LOAD_DO_NOT_SEND_COOKIES); | 397 LOAD_DO_NOT_SEND_COOKIES); |
| 397 | 398 |
| 398 if (http_request_method_ == "POST") { | 399 if (http_request_method_ == "POST") { |
| 399 DCHECK(!upload_content_.empty()); | 400 DCHECK(!upload_content_.empty()); |
| 400 DCHECK(!upload_content_type_.empty()); | 401 DCHECK(!upload_content_type_.empty()); |
| 401 | 402 |
| 402 request_->set_method("POST"); | 403 request_->set_method("POST"); |
| 403 extra_request_headers_.SetHeader( | 404 extra_request_headers_.SetHeader( |
| 404 HttpRequestHeaders::kContentType, upload_content_type_); | 405 HttpRequestHeaders::kContentType, upload_content_type_); |
| 405 | 406 |
| 406 scoped_refptr<UploadData> upload_data(new UploadData()); | 407 scoped_ptr<UploadElementReader> reader(new UploadBytesElementReader( |
| 407 upload_data->AppendBytes(upload_content_.data(), upload_content_.size()); | 408 upload_content_.data(), upload_content_.size())); |
| 408 request_->set_upload(upload_data); | 409 request_->set_upload(make_scoped_ptr( |
| 410 UploadDataStream::CreateWithReader(reader.Pass(), 0))); | |
| 409 } | 411 } |
| 410 if (!extra_request_headers_.IsEmpty()) | 412 if (!extra_request_headers_.IsEmpty()) |
| 411 request_->SetExtraRequestHeaders(extra_request_headers_); | 413 request_->SetExtraRequestHeaders(extra_request_headers_); |
| 412 | 414 |
| 413 request_->Start(); | 415 request_->Start(); |
| 414 AddRef(); // Release after |request_| deleted. | 416 AddRef(); // Release after |request_| deleted. |
| 415 } | 417 } |
| 416 | 418 |
| 417 GURL url_; // The URL we eventually wound up at | 419 GURL url_; // The URL we eventually wound up at |
| 418 std::string http_request_method_; | 420 std::string http_request_method_; |
| 419 base::TimeDelta timeout_; // The timeout for OCSP | 421 base::TimeDelta timeout_; // The timeout for OCSP |
| 420 URLRequest* request_; // The actual request this wraps | 422 URLRequest* request_; // The actual request this wraps |
|
mmenke
2012/12/13 16:44:40
Think it's worth mentioning that if upload_content
hashimoto
2012/12/13 17:39:12
Seems DCHECK(!request_) in the dtor guarantees tha
mmenke
2012/12/13 17:42:12
You're right that it currently does - I'm just bei
| |
| 421 scoped_refptr<IOBuffer> buffer_; // Read buffer | 423 scoped_refptr<IOBuffer> buffer_; // Read buffer |
| 422 HttpRequestHeaders extra_request_headers_; | 424 HttpRequestHeaders extra_request_headers_; |
| 423 std::string upload_content_; // HTTP POST payload | 425 std::string upload_content_; // HTTP POST payload |
| 424 std::string upload_content_type_; // MIME type of POST payload | 426 std::string upload_content_type_; // MIME type of POST payload |
| 425 | 427 |
| 426 int response_code_; // HTTP status code for the request | 428 int response_code_; // HTTP status code for the request |
| 427 std::string response_content_type_; | 429 std::string response_content_type_; |
| 428 scoped_refptr<HttpResponseHeaders> response_headers_; | 430 scoped_refptr<HttpResponseHeaders> response_headers_; |
| 429 std::string data_; // Results of the request | 431 std::string data_; // Results of the request |
| 430 | 432 |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 959 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { | 961 void SetURLRequestContextForNSSHttpIO(URLRequestContext* request_context) { |
| 960 pthread_mutex_lock(&g_request_context_lock); | 962 pthread_mutex_lock(&g_request_context_lock); |
| 961 if (request_context) { | 963 if (request_context) { |
| 962 DCHECK(!g_request_context); | 964 DCHECK(!g_request_context); |
| 963 } | 965 } |
| 964 g_request_context = request_context; | 966 g_request_context = request_context; |
| 965 pthread_mutex_unlock(&g_request_context_lock); | 967 pthread_mutex_unlock(&g_request_context_lock); |
| 966 } | 968 } |
| 967 | 969 |
| 968 } // namespace net | 970 } // namespace net |
| OLD | NEW |