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

Side by Side Diff: net/http/disk_cache_based_ssl_host_info.cc

Issue 8670009: SSL Host info: Make sure that we can update certificate chains in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: I Really hate this warning! Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/http/disk_cache_based_ssl_host_info.h" 5 #include "net/http/disk_cache_based_ssl_host_info.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 26 matching lines...) Expand all
37 const std::string& hostname, 37 const std::string& hostname,
38 const SSLConfig& ssl_config, 38 const SSLConfig& ssl_config,
39 CertVerifier* cert_verifier, 39 CertVerifier* cert_verifier,
40 HttpCache* http_cache) 40 HttpCache* http_cache)
41 : SSLHostInfo(hostname, ssl_config, cert_verifier), 41 : SSLHostInfo(hostname, ssl_config, cert_verifier),
42 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 42 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
43 callback_(new CallbackImpl(weak_ptr_factory_.GetWeakPtr(), 43 callback_(new CallbackImpl(weak_ptr_factory_.GetWeakPtr(),
44 &DiskCacheBasedSSLHostInfo::OnIOComplete)), 44 &DiskCacheBasedSSLHostInfo::OnIOComplete)),
45 state_(GET_BACKEND), 45 state_(GET_BACKEND),
46 ready_(false), 46 ready_(false),
47 found_entry_(false),
47 hostname_(hostname), 48 hostname_(hostname),
48 http_cache_(http_cache), 49 http_cache_(http_cache),
49 backend_(NULL), 50 backend_(NULL),
50 entry_(NULL), 51 entry_(NULL),
51 user_callback_(NULL) { 52 user_callback_(NULL) {
52 } 53 }
53 54
54 void DiskCacheBasedSSLHostInfo::Start() { 55 void DiskCacheBasedSSLHostInfo::Start() {
55 DCHECK(CalledOnValidThread()); 56 DCHECK(CalledOnValidThread());
56 DCHECK_EQ(GET_BACKEND, state_); 57 DCHECK_EQ(GET_BACKEND, state_);
(...skipping 18 matching lines...) Expand all
75 DCHECK(state_ != GET_BACKEND); 76 DCHECK(state_ != GET_BACKEND);
76 77
77 DCHECK(new_data_.empty()); 78 DCHECK(new_data_.empty());
78 CHECK(ready_); 79 CHECK(ready_);
79 DCHECK(user_callback_ == NULL); 80 DCHECK(user_callback_ == NULL);
80 new_data_ = Serialize(); 81 new_data_ = Serialize();
81 82
82 if (!backend_) 83 if (!backend_)
83 return; 84 return;
84 85
85 state_ = CREATE; 86 state_ = found_entry_ ? OPEN : CREATE;
86 DoLoop(OK); 87 DoLoop(OK);
87 } 88 }
88 89
89 DiskCacheBasedSSLHostInfo::~DiskCacheBasedSSLHostInfo() { 90 DiskCacheBasedSSLHostInfo::~DiskCacheBasedSSLHostInfo() {
90 DCHECK(!user_callback_); 91 DCHECK(!user_callback_);
91 if (entry_) 92 if (entry_)
92 entry_->Close(); 93 entry_->Close();
93 if (!IsCallbackPending()) 94 if (!IsCallbackPending())
94 delete callback_; 95 delete callback_;
95 } 96 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (rv == OK) { 161 if (rv == OK) {
161 backend_ = callback_->backend(); 162 backend_ = callback_->backend();
162 state_ = OPEN; 163 state_ = OPEN;
163 } else { 164 } else {
164 state_ = WAIT_FOR_DATA_READY_DONE; 165 state_ = WAIT_FOR_DATA_READY_DONE;
165 } 166 }
166 return OK; 167 return OK;
167 } 168 }
168 169
169 int DiskCacheBasedSSLHostInfo::DoOpenComplete(int rv) { 170 int DiskCacheBasedSSLHostInfo::DoOpenComplete(int rv) {
171 if (found_entry_) {
172 state_ = CREATE_COMPLETE;
173 return rv;
174 }
wtc 2011/11/30 00:22:09 Instead of checking found_entry_ here, I suggest w
175
170 if (rv == OK) { 176 if (rv == OK) {
171 entry_ = callback_->entry(); 177 entry_ = callback_->entry();
172 state_ = READ; 178 state_ = READ;
179 found_entry_ = true;
173 } else { 180 } else {
174 state_ = WAIT_FOR_DATA_READY_DONE; 181 state_ = WAIT_FOR_DATA_READY_DONE;
175 } 182 }
176 183
177 return OK; 184 return OK;
178 } 185 }
179 186
180 int DiskCacheBasedSSLHostInfo::DoReadComplete(int rv) { 187 int DiskCacheBasedSSLHostInfo::DoReadComplete(int rv) {
181 if (rv > 0) 188 if (rv > 0)
182 data_.assign(read_buffer_->data(), rv); 189 data_.assign(read_buffer_->data(), rv);
(...skipping 16 matching lines...) Expand all
199 } 206 }
200 return OK; 207 return OK;
201 } 208 }
202 209
203 int DiskCacheBasedSSLHostInfo::DoGetBackend() { 210 int DiskCacheBasedSSLHostInfo::DoGetBackend() {
204 state_ = GET_BACKEND_COMPLETE; 211 state_ = GET_BACKEND_COMPLETE;
205 return http_cache_->GetBackend(callback_->backend_pointer(), callback_); 212 return http_cache_->GetBackend(callback_->backend_pointer(), callback_);
206 } 213 }
207 214
208 int DiskCacheBasedSSLHostInfo::DoOpen() { 215 int DiskCacheBasedSSLHostInfo::DoOpen() {
209 state_ = OPEN_COMPLETE; 216 state_ = OPEN_COMPLETE;
wtc 2011/11/30 00:22:09 I suggest we do state_ = found_entry_ ? CREATE_C
210 return backend_->OpenEntry(key(), callback_->entry_pointer(), callback_); 217 return backend_->OpenEntry(key(), callback_->entry_pointer(), callback_);
211 } 218 }
212 219
213 int DiskCacheBasedSSLHostInfo::DoRead() { 220 int DiskCacheBasedSSLHostInfo::DoRead() {
214 const int32 size = entry_->GetDataSize(0 /* index */); 221 const int32 size = entry_->GetDataSize(0 /* index */);
215 if (!size) { 222 if (!size) {
216 state_ = WAIT_FOR_DATA_READY_DONE; 223 state_ = WAIT_FOR_DATA_READY_DONE;
217 return OK; 224 return OK;
218 } 225 }
219 226
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 case READ_COMPLETE: 273 case READ_COMPLETE:
267 case CREATE_COMPLETE: 274 case CREATE_COMPLETE:
268 case WRITE_COMPLETE: 275 case WRITE_COMPLETE:
269 return true; 276 return true;
270 default: 277 default:
271 return false; 278 return false;
272 } 279 }
273 } 280 }
274 281
275 } // namespace net 282 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698