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

Unified Diff: net/http/disk_based_cert_cache.cc

Issue 465633003: Updates state order of DiskBasedCertCache::WriteWorker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/disk_based_cert_cache.cc
diff --git a/net/http/disk_based_cert_cache.cc b/net/http/disk_based_cert_cache.cc
index fc98b064c0213bc801015038bb3a7ff37369274e..d7d3d2f723758a40d8db17844d17e712c76a167e 100644
--- a/net/http/disk_based_cert_cache.cc
+++ b/net/http/disk_based_cert_cache.cc
@@ -81,10 +81,10 @@ class DiskBasedCertCache::WriteWorker {
private:
enum State {
- STATE_CREATE,
- STATE_CREATE_COMPLETE,
STATE_OPEN,
STATE_OPEN_COMPLETE,
+ STATE_CREATE,
+ STATE_CREATE_COMPLETE,
STATE_WRITE,
STATE_WRITE_COMPLETE,
STATE_NONE
@@ -93,10 +93,10 @@ class DiskBasedCertCache::WriteWorker {
void OnIOComplete(int rv);
int DoLoop(int rv);
- int DoCreate();
- int DoCreateComplete(int rv);
int DoOpen();
int DoOpenComplete(int rv);
+ int DoCreate();
+ int DoCreateComplete(int rv);
int DoWrite();
int DoWriteComplete(int rv);
@@ -146,7 +146,8 @@ DiskBasedCertCache::WriteWorker::~WriteWorker() {
void DiskBasedCertCache::WriteWorker::Start() {
DCHECK_EQ(STATE_NONE, next_state_);
- next_state_ = STATE_CREATE;
+
+ next_state_ = STATE_OPEN;
int rv = DoLoop(OK);
if (rv == ERR_IO_PENDING)
@@ -183,18 +184,18 @@ int DiskBasedCertCache::WriteWorker::DoLoop(int rv) {
State state = next_state_;
next_state_ = STATE_NONE;
switch (state) {
- case STATE_CREATE:
- rv = DoCreate();
- break;
- case STATE_CREATE_COMPLETE:
- rv = DoCreateComplete(rv);
- break;
case STATE_OPEN:
rv = DoOpen();
break;
case STATE_OPEN_COMPLETE:
rv = DoOpenComplete(rv);
break;
+ case STATE_CREATE:
+ rv = DoCreate();
+ break;
+ case STATE_CREATE_COMPLETE:
+ rv = DoCreateComplete(rv);
+ break;
case STATE_WRITE:
rv = DoWrite();
break;
@@ -210,18 +211,15 @@ int DiskBasedCertCache::WriteWorker::DoLoop(int rv) {
return rv;
}
-int DiskBasedCertCache::WriteWorker::DoCreate() {
- next_state_ = STATE_CREATE_COMPLETE;
-
- return backend_->CreateEntry(key_, &entry_, io_callback_);
+int DiskBasedCertCache::WriteWorker::DoOpen() {
+ next_state_ = STATE_OPEN_COMPLETE;
+ return backend_->OpenEntry(key_, &entry_, io_callback_);
}
-int DiskBasedCertCache::WriteWorker::DoCreateComplete(int rv) {
- // An error here usually signifies that the entry already exists.
- // If this occurs, it is necessary to instead open the previously
- // existing entry.
+int DiskBasedCertCache::WriteWorker::DoOpenComplete(int rv) {
+ // The entry doesn't exist yet, so we should create it.
if (rv < 0) {
- next_state_ = STATE_OPEN;
+ next_state_ = STATE_CREATE;
return OK;
}
@@ -229,12 +227,12 @@ int DiskBasedCertCache::WriteWorker::DoCreateComplete(int rv) {
return OK;
}
-int DiskBasedCertCache::WriteWorker::DoOpen() {
- next_state_ = STATE_OPEN_COMPLETE;
- return backend_->OpenEntry(key_, &entry_, io_callback_);
+int DiskBasedCertCache::WriteWorker::DoCreate() {
+ next_state_ = STATE_CREATE_COMPLETE;
+ return backend_->CreateEntry(key_, &entry_, io_callback_);
}
-int DiskBasedCertCache::WriteWorker::DoOpenComplete(int rv) {
+int DiskBasedCertCache::WriteWorker::DoCreateComplete(int rv) {
if (rv < 0)
return rv;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698