summaryrefslogtreecommitdiffstats
path: root/net/ocsp
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-26 12:11:49 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-26 12:11:49 +0000
commit3db2774506665f31721ff4b0f894c23129a202df (patch)
treea723b7d1ff3ad2e5cb3cd5a5579cef32c19e00e1 /net/ocsp
parent6666e5bf840b8198909a9207604855f4e8dbc2af (diff)
downloadchromium_src-3db2774506665f31721ff4b0f894c23129a202df.zip
chromium_src-3db2774506665f31721ff4b0f894c23129a202df.tar.gz
chromium_src-3db2774506665f31721ff4b0f894c23129a202df.tar.bz2
Minor cleanup of NSS OCSP functionality
- Properly handle IPv6 responder URLs - Remove unnecessary net:: namespace qualifiers by moving the unnnamed namespace into net:: BUG=none Review URL: https://chromiumcodereview.appspot.com/10868086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153411 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ocsp')
-rw-r--r--net/ocsp/nss_ocsp.cc61
1 files changed, 29 insertions, 32 deletions
diff --git a/net/ocsp/nss_ocsp.cc b/net/ocsp/nss_ocsp.cc
index 273e341..5abdd93 100644
--- a/net/ocsp/nss_ocsp.cc
+++ b/net/ocsp/nss_ocsp.cc
@@ -29,6 +29,7 @@
#include "base/threading/thread_checker.h"
#include "base/time.h"
#include "googleurl/src/gurl.h"
+#include "net/base/host_port_pair.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
@@ -36,11 +37,13 @@
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
+namespace net {
+
namespace {
// Protects |g_request_context|.
pthread_mutex_t g_request_context_lock = PTHREAD_MUTEX_INITIALIZER;
-static net::URLRequestContext* g_request_context = NULL;
+URLRequestContext* g_request_context = NULL;
class OCSPRequestSession;
@@ -144,13 +147,13 @@ base::LazyInstance<OCSPNSSInitialization> g_ocsp_nss_initialization =
LAZY_INSTANCE_INITIALIZER;
// Concrete class for SEC_HTTP_REQUEST_SESSION.
-// Public methods except virtual methods of net::URLRequest::Delegate
+// Public methods except virtual methods of URLRequest::Delegate
// (On* methods) run on certificate verifier thread (worker thread).
-// Virtual methods of net::URLRequest::Delegate and private methods run
+// Virtual methods of URLRequest::Delegate and private methods run
// on IO thread.
class OCSPRequestSession
: public base::RefCountedThreadSafe<OCSPRequestSession>,
- public net::URLRequest::Delegate {
+ public URLRequest::Delegate {
public:
OCSPRequestSession(const GURL& url,
const char* http_request_method,
@@ -159,7 +162,7 @@ class OCSPRequestSession
http_request_method_(http_request_method),
timeout_(timeout),
request_(NULL),
- buffer_(new net::IOBuffer(kRecvBufferSize)),
+ buffer_(new IOBuffer(kRecvBufferSize)),
response_code_(-1),
cv_(&lock_),
io_loop_(NULL),
@@ -252,7 +255,7 @@ class OCSPRequestSession
return data_;
}
- virtual void OnReceivedRedirect(net::URLRequest* request,
+ virtual void OnReceivedRedirect(URLRequest* request,
const GURL& new_url,
bool* defer_redirect) OVERRIDE {
DCHECK_EQ(request, request_);
@@ -265,7 +268,7 @@ class OCSPRequestSession
}
}
- virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE {
+ virtual void OnResponseStarted(URLRequest* request) OVERRIDE {
DCHECK_EQ(request, request_);
DCHECK_EQ(MessageLoopForIO::current(), io_loop_);
@@ -279,7 +282,7 @@ class OCSPRequestSession
OnReadCompleted(request_, bytes_read);
}
- virtual void OnReadCompleted(net::URLRequest* request,
+ virtual void OnReadCompleted(URLRequest* request,
int bytes_read) OVERRIDE {
DCHECK_EQ(request, request_);
DCHECK_EQ(MessageLoopForIO::current(), io_loop_);
@@ -354,7 +357,7 @@ class OCSPRequestSession
DCHECK(!request_);
pthread_mutex_lock(&g_request_context_lock);
- net::URLRequestContext* url_request_context = g_request_context;
+ URLRequestContext* url_request_context = g_request_context;
pthread_mutex_unlock(&g_request_context_lock);
if (url_request_context == NULL)
@@ -367,11 +370,10 @@ class OCSPRequestSession
g_ocsp_io_loop.Get().AddRequest(this);
}
- request_ = new net::URLRequest(url_, this, url_request_context);
+ request_ = new URLRequest(url_, this, url_request_context);
// To meet the privacy requirements of incognito mode.
- request_->set_load_flags(
- net::LOAD_DISABLE_CACHE | net::LOAD_DO_NOT_SAVE_COOKIES |
- net::LOAD_DO_NOT_SEND_COOKIES);
+ request_->set_load_flags(LOAD_DISABLE_CACHE | LOAD_DO_NOT_SAVE_COOKIES |
+ LOAD_DO_NOT_SEND_COOKIES);
if (http_request_method_ == "POST") {
DCHECK(!upload_content_.empty());
@@ -379,7 +381,7 @@ class OCSPRequestSession
request_->set_method("POST");
extra_request_headers_.SetHeader(
- net::HttpRequestHeaders::kContentType, upload_content_type_);
+ HttpRequestHeaders::kContentType, upload_content_type_);
request_->AppendBytesToUpload(upload_content_.data(),
static_cast<int>(upload_content_.size()));
}
@@ -393,15 +395,15 @@ class OCSPRequestSession
GURL url_; // The URL we eventually wound up at
std::string http_request_method_;
base::TimeDelta timeout_; // The timeout for OCSP
- net::URLRequest* request_; // The actual request this wraps
- scoped_refptr<net::IOBuffer> buffer_; // Read buffer
- net::HttpRequestHeaders extra_request_headers_;
+ URLRequest* request_; // The actual request this wraps
+ scoped_refptr<IOBuffer> buffer_; // Read buffer
+ HttpRequestHeaders extra_request_headers_;
std::string upload_content_; // HTTP POST payload
std::string upload_content_type_; // MIME type of POST payload
int response_code_; // HTTP status code for the request
std::string response_content_type_;
- scoped_refptr<net::HttpResponseHeaders> response_headers_;
+ scoped_refptr<HttpResponseHeaders> response_headers_;
std::string data_; // Results of the requst
// |lock_| protects |finished_| and |io_loop_|.
@@ -418,7 +420,7 @@ class OCSPRequestSession
class OCSPServerSession {
public:
OCSPServerSession(const char* host, PRUint16 port)
- : host_(host), port_(port) {}
+ : host_and_port_(host, port) {}
~OCSPServerSession() {}
OCSPRequestSession* CreateRequest(const char* http_protocol_variant,
@@ -433,13 +435,11 @@ class OCSPServerSession {
return NULL;
}
- // TODO(ukai): If |host| is an IPv6 literal, we need to quote it with
- // square brackets [].
- std::string url_string(base::StringPrintf("%s://%s:%d%s",
- http_protocol_variant,
- host_.c_str(),
- port_,
- path_and_query_string));
+ std::string url_string(base::StringPrintf(
+ "%s://%s%s",
+ http_protocol_variant,
+ host_and_port_.ToString().c_str(),
+ path_and_query_string));
VLOG(1) << "URL [" << url_string << "]";
GURL url(url_string);
return new OCSPRequestSession(
@@ -449,8 +449,7 @@ class OCSPServerSession {
private:
- std::string host_;
- int port_;
+ HostPortPair host_and_port_;
DISALLOW_COPY_AND_ASSIGN(OCSPServerSession);
};
@@ -574,13 +573,13 @@ SECStatus OCSPCreateSession(const char* host, PRUint16 portnum,
SEC_HTTP_SERVER_SESSION* pSession) {
VLOG(1) << "OCSP create session: host=" << host << " port=" << portnum;
pthread_mutex_lock(&g_request_context_lock);
- net::URLRequestContext* request_context = g_request_context;
+ URLRequestContext* request_context = g_request_context;
pthread_mutex_unlock(&g_request_context_lock);
if (request_context == NULL) {
LOG(ERROR) << "No URLRequestContext for NSS HTTP handler. host: " << host;
// The application failed to call SetURLRequestContextForNSSHttpIO or
// has already called ShutdownNSSHttpIO, so we can't create and use
- // net::URLRequest. PR_NOT_IMPLEMENTED_ERROR is not an accurate error
+ // URLRequest. PR_NOT_IMPLEMENTED_ERROR is not an accurate error
// code for these error conditions, but is close enough.
PORT_SetError(PR_NOT_IMPLEMENTED_ERROR);
return SECFailure;
@@ -906,8 +905,6 @@ char* GetAlternateOCSPAIAInfo(CERTCertificate *cert) {
} // anonymous namespace
-namespace net {
-
void SetMessageLoopForNSSHttpIO() {
// Must have a MessageLoopForIO.
DCHECK(MessageLoopForIO::current());