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

Unified Diff: net/base/server_bound_cert_service.cc

Issue 11689002: Fix for spdy cancelling ServerBoundCertServiceRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NET_EXPORT the RequestHandle Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/server_bound_cert_service.h ('k') | net/base/server_bound_cert_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/server_bound_cert_service.cc
diff --git a/net/base/server_bound_cert_service.cc b/net/base/server_bound_cert_service.cc
index 52e3d42adb12a5cd5c7721337697f86d997e8e74..3194a6623ad2491e3b9fb1a4f672ac3aebe2e326 100644
--- a/net/base/server_bound_cert_service.cc
+++ b/net/base/server_bound_cert_service.cc
@@ -349,6 +349,38 @@ class ServerBoundCertServiceJob {
// static
const char ServerBoundCertService::kEPKIPassword[] = "";
+ServerBoundCertService::RequestHandle::RequestHandle()
+ : service_(NULL),
+ request_(NULL) {}
+
+ServerBoundCertService::RequestHandle::~RequestHandle() {
+ Cancel();
+}
+
+void ServerBoundCertService::RequestHandle::Cancel() {
+ if (request_) {
+ service_->CancelRequest(request_);
+ request_ = NULL;
+ callback_.Reset();
+ }
+}
+
+void ServerBoundCertService::RequestHandle::RequestStarted(
+ ServerBoundCertService* service,
+ ServerBoundCertServiceRequest* request,
+ const CompletionCallback& callback) {
+ DCHECK(request_ == NULL);
+ service_ = service;
+ request_ = request;
+ callback_ = callback;
+}
+
+void ServerBoundCertService::RequestHandle::OnRequestComplete(int result) {
+ request_ = NULL;
+ callback_.Run(result);
+ callback_.Reset();
+}
+
ServerBoundCertService::ServerBoundCertService(
ServerBoundCertStore* server_bound_cert_store,
const scoped_refptr<base::TaskRunner>& task_runner)
@@ -391,8 +423,6 @@ int ServerBoundCertService::GetDomainBoundCert(
DCHECK(CalledOnValidThread());
base::TimeTicks request_start = base::TimeTicks::Now();
- *out_req = NULL;
-
if (callback.is_null() || !private_key || !cert || origin.empty() ||
requested_types.empty()) {
RecordGetDomainBoundCertResult(INVALID_ARGUMENT);
@@ -491,9 +521,11 @@ int ServerBoundCertService::GetDomainBoundCert(
}
ServerBoundCertServiceRequest* request = new ServerBoundCertServiceRequest(
- request_start, callback, type, private_key, cert);
+ request_start,
+ base::Bind(&RequestHandle::OnRequestComplete, base::Unretained(out_req)),
+ type, private_key, cert);
job->AddRequest(request);
- *out_req = request;
+ out_req->RequestStarted(this, request, callback);
return ERR_IO_PENDING;
}
@@ -501,11 +533,9 @@ ServerBoundCertStore* ServerBoundCertService::GetCertStore() {
return server_bound_cert_store_.get();
}
-void ServerBoundCertService::CancelRequest(RequestHandle req) {
+void ServerBoundCertService::CancelRequest(ServerBoundCertServiceRequest* req) {
DCHECK(CalledOnValidThread());
- ServerBoundCertServiceRequest* request =
- reinterpret_cast<ServerBoundCertServiceRequest*>(req);
- request->Cancel();
+ req->Cancel();
}
// HandleResult is called by ServerBoundCertServiceWorker on the origin message
« no previous file with comments | « net/base/server_bound_cert_service.h ('k') | net/base/server_bound_cert_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698