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

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

Issue 361513003: Improving and adding an in-memory MRU cache to DiskBasedCertCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DBCC_Implement
Patch Set: Removed static cast. Created 6 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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_based_cert_cache.h" 5 #include "net/http/disk_based_cert_cache.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/disk_cache/disk_cache.h" 16 #include "net/disk_cache/disk_cache.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 namespace { 20 namespace {
21 21
22 // TODO(brandonsalmon): change this number to improve performance.
23 const size_t kMemoryCacheMaxSize = 30;
24
22 // Used to obtain a unique cache key for a certificate in the form of 25 // Used to obtain a unique cache key for a certificate in the form of
23 // "cert:<hash>". 26 // "cert:<hash>".
24 std::string GetCacheKeyToCert(const X509Certificate::OSCertHandle cert_handle) { 27 std::string GetCacheKeyToCert(const X509Certificate::OSCertHandle cert_handle) {
25 SHA1HashValue fingerprint = 28 SHA1HashValue fingerprint =
26 X509Certificate::CalculateFingerprint(cert_handle); 29 X509Certificate::CalculateFingerprint(cert_handle);
27 30
28 return "cert:" + 31 return "cert:" +
29 base::HexEncode(fingerprint.data, arraysize(fingerprint.data)); 32 base::HexEncode(fingerprint.data, arraysize(fingerprint.data));
30 } 33 }
31 34
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 std::vector<SetCallback> user_callbacks_; 104 std::vector<SetCallback> user_callbacks_;
102 CompletionCallback io_callback_; 105 CompletionCallback io_callback_;
103 }; 106 };
104 107
105 DiskBasedCertCache::WriteWorker::WriteWorker( 108 DiskBasedCertCache::WriteWorker::WriteWorker(
106 disk_cache::Backend* backend, 109 disk_cache::Backend* backend,
107 const std::string& key, 110 const std::string& key,
108 X509Certificate::OSCertHandle cert_handle, 111 X509Certificate::OSCertHandle cert_handle,
109 const base::Closure& cleanup_callback) 112 const base::Closure& cleanup_callback)
110 : backend_(backend), 113 : backend_(backend),
111 cert_handle_(cert_handle), 114 cert_handle_(X509Certificate::DupOSCertHandle(cert_handle)),
112 key_(key), 115 key_(key),
113 canceled_(false), 116 canceled_(false),
114 entry_(NULL), 117 entry_(NULL),
115 state_(STATE_NONE), 118 state_(STATE_NONE),
116 io_buf_len_(0), 119 io_buf_len_(0),
117 cleanup_callback_(cleanup_callback), 120 cleanup_callback_(cleanup_callback),
118 io_callback_( 121 io_callback_(
119 base::Bind(&WriteWorker::OnIOComplete, base::Unretained(this))) { 122 base::Bind(&WriteWorker::OnIOComplete, base::Unretained(this))) {
120 } 123 }
121 124
125 DiskBasedCertCache::WriteWorker::~WriteWorker() {
wtc 2014/07/03 02:37:13 Nit: make this and the ReadWorker destructor the s
126 X509Certificate::FreeOSCertHandle(cert_handle_);
127 if (entry_)
128 entry_->Close();
129 }
130
122 void DiskBasedCertCache::WriteWorker::Start() { 131 void DiskBasedCertCache::WriteWorker::Start() {
123 DCHECK_EQ(STATE_NONE, state_); 132 DCHECK_EQ(STATE_NONE, state_);
124 state_ = STATE_CREATE; 133 state_ = STATE_CREATE;
125 int rv = DoLoop(OK); 134 int rv = DoLoop(OK);
126 135
127 if (rv == ERR_IO_PENDING) 136 if (rv == ERR_IO_PENDING)
128 return; 137 return;
129 138
130 Finish(rv); 139 Finish(rv);
131 } 140 }
132 141
133 void DiskBasedCertCache::WriteWorker::AddCallback( 142 void DiskBasedCertCache::WriteWorker::AddCallback(
134 const SetCallback& user_callback) { 143 const SetCallback& user_callback) {
135 user_callbacks_.push_back(user_callback); 144 user_callbacks_.push_back(user_callback);
136 } 145 }
137 146
147 void DiskBasedCertCache::WriteWorker::Cancel() {
148 canceled_ = true;
149 }
150
138 void DiskBasedCertCache::WriteWorker::OnIOComplete(int rv) { 151 void DiskBasedCertCache::WriteWorker::OnIOComplete(int rv) {
139 if (canceled_) { 152 if (canceled_) {
140 Finish(ERR_FAILED); 153 Finish(ERR_FAILED);
141 return; 154 return;
142 } 155 }
143 156
144 rv = DoLoop(rv); 157 rv = DoLoop(rv);
145 158
146 if (rv == ERR_IO_PENDING) 159 if (rv == ERR_IO_PENDING)
147 return; 160 return;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 state_ = STATE_WRITE; 212 state_ = STATE_WRITE;
200 return OK; 213 return OK;
201 } 214 }
202 215
203 int DiskBasedCertCache::WriteWorker::DoOpen() { 216 int DiskBasedCertCache::WriteWorker::DoOpen() {
204 state_ = STATE_OPEN_COMPLETE; 217 state_ = STATE_OPEN_COMPLETE;
205 return backend_->OpenEntry(key_, &entry_, io_callback_); 218 return backend_->OpenEntry(key_, &entry_, io_callback_);
206 } 219 }
207 220
208 int DiskBasedCertCache::WriteWorker::DoOpenComplete(int rv) { 221 int DiskBasedCertCache::WriteWorker::DoOpenComplete(int rv) {
209 if (rv < 0) { 222 if (rv < 0)
210 state_ = STATE_NONE;
211 return rv; 223 return rv;
212 } 224
213 state_ = STATE_WRITE; 225 state_ = STATE_WRITE;
214 return OK; 226 return OK;
215 } 227 }
216 228
217 int DiskBasedCertCache::WriteWorker::DoWrite() { 229 int DiskBasedCertCache::WriteWorker::DoWrite() {
218 std::string write_data; 230 std::string write_data;
219 bool encoded = X509Certificate::GetDEREncoded(cert_handle_, &write_data); 231 bool encoded = X509Certificate::GetDEREncoded(cert_handle_, &write_data);
220 232
221 if (!encoded) { 233 if (!encoded)
222 state_ = STATE_NONE;
223 return ERR_FAILED; 234 return ERR_FAILED;
224 }
225 235
226 buffer_ = new IOBuffer(write_data.size()); 236 buffer_ = new IOBuffer(write_data.size());
227 io_buf_len_ = write_data.size(); 237 io_buf_len_ = write_data.size();
228 memcpy(buffer_->data(), write_data.data(), io_buf_len_); 238 memcpy(buffer_->data(), write_data.data(), io_buf_len_);
229 239
230 state_ = STATE_WRITE_COMPLETE; 240 state_ = STATE_WRITE_COMPLETE;
231 241
232 return entry_->WriteData(0 /* index */, 242 return entry_->WriteData(0 /* index */,
233 0 /* offset */, 243 0 /* offset */,
234 buffer_, 244 buffer_,
235 write_data.size(), 245 write_data.size(),
236 io_callback_, 246 io_callback_,
237 true /* truncate */); 247 true /* truncate */);
238 } 248 }
239 249
240 int DiskBasedCertCache::WriteWorker::DoWriteComplete(int rv) { 250 int DiskBasedCertCache::WriteWorker::DoWriteComplete(int rv) {
241 state_ = STATE_NONE;
242 if (rv < io_buf_len_) 251 if (rv < io_buf_len_)
243 return ERR_FAILED; 252 return ERR_FAILED;
244 253
245 return OK; 254 return OK;
246 } 255 }
247 256
257 void DiskBasedCertCache::WriteWorker::Finish(int rv) {
258 cleanup_callback_.Run();
259 cleanup_callback_.Reset();
260 RunCallbacks(rv);
261 delete this;
262 }
263
248 void DiskBasedCertCache::WriteWorker::RunCallbacks(int rv) { 264 void DiskBasedCertCache::WriteWorker::RunCallbacks(int rv) {
249 std::string key; 265 std::string key;
250 if (rv >= 0) 266 if (rv >= 0)
251 key = key_; 267 key = key_;
252 268
253 for (std::vector<SetCallback>::const_iterator it = user_callbacks_.begin(); 269 for (std::vector<SetCallback>::const_iterator it = user_callbacks_.begin();
254 it != user_callbacks_.end(); 270 it != user_callbacks_.end();
255 ++it) { 271 ++it) {
256 it->Run(key); 272 it->Run(key);
257 } 273 }
258 user_callbacks_.clear(); 274 user_callbacks_.clear();
259 } 275 }
260 276
261 void DiskBasedCertCache::WriteWorker::Finish(int rv) {
262 cleanup_callback_.Run();
263 cleanup_callback_.Reset();
264 RunCallbacks(rv);
265 delete this;
266 }
267
268 void DiskBasedCertCache::WriteWorker::Cancel() {
269 canceled_ = true;
270 }
271
272 DiskBasedCertCache::WriteWorker::~WriteWorker() {
273 if (entry_)
274 entry_->Close();
275 }
276
277 // ReadWorkers represent pending Get jobs in the DiskBasedCertCache. Each 277 // ReadWorkers represent pending Get jobs in the DiskBasedCertCache. Each
278 // certificate requested to be retrieved from the cache is assigned a ReadWorker 278 // certificate requested to be retrieved from the cache is assigned a ReadWorker
279 // on a one-to-one basis. The same |key| should not have multiple ReadWorkers 279 // on a one-to-one basis. The same |key| should not have multiple ReadWorkers
280 // at the same time; instead, call AddCallback to add a user_callback_ to 280 // at the same time; instead, call AddCallback to add a user_callback_ to
281 // the the existing ReadWorker. 281 // the the existing ReadWorker.
282 class DiskBasedCertCache::ReadWorker { 282 class DiskBasedCertCache::ReadWorker {
283 public: 283 public:
284 // |backend| is the backend to read |certificate| from, using 284 // |backend| is the backend to read |certificate| from, using
285 // |key| as the key for the disk_cache::Entry. 285 // |key| as the key for the disk_cache::Entry.
286 // |cleanup_callback| is called to clean up this ReadWorker, 286 // |cleanup_callback| is called to clean up this ReadWorker,
287 // regardless of success or failure. 287 // regardless of success or failure.
288 ReadWorker(disk_cache::Backend* backend, 288 ReadWorker(disk_cache::Backend* backend,
289 const std::string& key, 289 const std::string& key,
290 const base::Closure& cleanup_callback); 290 const GetCallback& cleanup_callback);
291 291
292 ~ReadWorker(); 292 ~ReadWorker();
293 293
294 // Reads the given certificate from the cache. On completion, will invoke all 294 // Reads the given certificate from the cache. On completion, will invoke all
295 // user callbacks. 295 // user callbacks.
296 void Start(); 296 void Start();
297 297
298 // Adds a callback to the set of callbacks to be run when this 298 // Adds a callback to the set of callbacks to be run when this
299 // ReadWorker finishes processing. 299 // ReadWorker finishes processing.
300 void AddCallback(const GetCallback& user_callback); 300 void AddCallback(const GetCallback& user_callback);
(...skipping 27 matching lines...) Expand all
328 X509Certificate::OSCertHandle cert_handle_; 328 X509Certificate::OSCertHandle cert_handle_;
329 std::string key_; 329 std::string key_;
330 bool canceled_; 330 bool canceled_;
331 331
332 disk_cache::Entry* entry_; 332 disk_cache::Entry* entry_;
333 333
334 State state_; 334 State state_;
335 scoped_refptr<IOBuffer> buffer_; 335 scoped_refptr<IOBuffer> buffer_;
336 int io_buf_len_; 336 int io_buf_len_;
337 337
338 base::Closure cleanup_callback_; 338 GetCallback cleanup_callback_;
339 std::vector<GetCallback> user_callbacks_; 339 std::vector<GetCallback> user_callbacks_;
340 CompletionCallback io_callback_; 340 CompletionCallback io_callback_;
341 }; 341 };
342 342
343 DiskBasedCertCache::ReadWorker::ReadWorker( 343 DiskBasedCertCache::ReadWorker::ReadWorker(disk_cache::Backend* backend,
344 disk_cache::Backend* backend, 344 const std::string& key,
345 const std::string& key, 345 const GetCallback& cleanup_callback)
346 const base::Closure& cleanup_callback)
347 : backend_(backend), 346 : backend_(backend),
348 cert_handle_(NULL), 347 cert_handle_(NULL),
349 key_(key), 348 key_(key),
350 canceled_(false), 349 canceled_(false),
351 entry_(NULL), 350 entry_(NULL),
352 state_(STATE_NONE), 351 state_(STATE_NONE),
353 io_buf_len_(0), 352 io_buf_len_(0),
354 cleanup_callback_(cleanup_callback), 353 cleanup_callback_(cleanup_callback),
355 io_callback_( 354 io_callback_(
356 base::Bind(&ReadWorker::OnIOComplete, base::Unretained(this))) { 355 base::Bind(&ReadWorker::OnIOComplete, base::Unretained(this))) {
357 } 356 }
358 357
358 DiskBasedCertCache::ReadWorker::~ReadWorker() {
359 if (entry_)
360 entry_->Close();
361 if (cert_handle_)
362 X509Certificate::FreeOSCertHandle(cert_handle_);
363 }
364
359 void DiskBasedCertCache::ReadWorker::Start() { 365 void DiskBasedCertCache::ReadWorker::Start() {
360 DCHECK_EQ(STATE_NONE, state_); 366 DCHECK_EQ(STATE_NONE, state_);
361 state_ = STATE_OPEN; 367 state_ = STATE_OPEN;
362 int rv = DoLoop(OK); 368 int rv = DoLoop(OK);
363 369
364 if (rv == ERR_IO_PENDING) 370 if (rv == ERR_IO_PENDING)
365 return; 371 return;
366 372
367 Finish(rv); 373 Finish(rv);
368 } 374 }
369 375
370 void DiskBasedCertCache::ReadWorker::AddCallback( 376 void DiskBasedCertCache::ReadWorker::AddCallback(
371 const GetCallback& user_callback) { 377 const GetCallback& user_callback) {
372 user_callbacks_.push_back(user_callback); 378 user_callbacks_.push_back(user_callback);
373 } 379 }
374 380
381 void DiskBasedCertCache::ReadWorker::Cancel() {
382 canceled_ = true;
383 }
384
375 void DiskBasedCertCache::ReadWorker::OnIOComplete(int rv) { 385 void DiskBasedCertCache::ReadWorker::OnIOComplete(int rv) {
376 if (canceled_) { 386 if (canceled_) {
377 Finish(ERR_FAILED); 387 Finish(ERR_FAILED);
378 return; 388 return;
379 } 389 }
380 390
381 rv = DoLoop(rv); 391 rv = DoLoop(rv);
382 392
383 if (rv == ERR_IO_PENDING) 393 if (rv == ERR_IO_PENDING)
384 return; 394 return;
(...skipping 26 matching lines...) Expand all
411 421
412 return rv; 422 return rv;
413 } 423 }
414 424
415 int DiskBasedCertCache::ReadWorker::DoOpen() { 425 int DiskBasedCertCache::ReadWorker::DoOpen() {
416 state_ = STATE_OPEN_COMPLETE; 426 state_ = STATE_OPEN_COMPLETE;
417 return backend_->OpenEntry(key_, &entry_, io_callback_); 427 return backend_->OpenEntry(key_, &entry_, io_callback_);
418 } 428 }
419 429
420 int DiskBasedCertCache::ReadWorker::DoOpenComplete(int rv) { 430 int DiskBasedCertCache::ReadWorker::DoOpenComplete(int rv) {
421 if (rv < 0) { 431 if (rv < 0)
422 state_ = STATE_NONE;
423 return rv; 432 return rv;
424 } 433
425 state_ = STATE_READ; 434 state_ = STATE_READ;
426 return OK; 435 return OK;
427 } 436 }
428 437
429 int DiskBasedCertCache::ReadWorker::DoRead() { 438 int DiskBasedCertCache::ReadWorker::DoRead() {
430 state_ = STATE_READ_COMPLETE; 439 state_ = STATE_READ_COMPLETE;
431 io_buf_len_ = entry_->GetDataSize(0 /* index */); 440 io_buf_len_ = entry_->GetDataSize(0 /* index */);
432 buffer_ = new IOBuffer(io_buf_len_); 441 buffer_ = new IOBuffer(io_buf_len_);
433 return entry_->ReadData( 442 return entry_->ReadData(
434 0 /* index */, 0 /* offset */, buffer_, io_buf_len_, io_callback_); 443 0 /* index */, 0 /* offset */, buffer_, io_buf_len_, io_callback_);
435 } 444 }
436 445
437 int DiskBasedCertCache::ReadWorker::DoReadComplete(int rv) { 446 int DiskBasedCertCache::ReadWorker::DoReadComplete(int rv) {
438 state_ = STATE_NONE;
439 if (rv < io_buf_len_) 447 if (rv < io_buf_len_)
440 return ERR_FAILED; 448 return ERR_FAILED;
441 449
442 cert_handle_ = X509Certificate::CreateOSCertHandleFromBytes(buffer_->data(), 450 cert_handle_ = X509Certificate::CreateOSCertHandleFromBytes(buffer_->data(),
443 io_buf_len_); 451 io_buf_len_);
444 if (!cert_handle_) 452 if (!cert_handle_)
445 return ERR_FAILED; 453 return ERR_FAILED;
446 454
447 return OK; 455 return OK;
448 } 456 }
449 457
458 void DiskBasedCertCache::ReadWorker::Finish(int rv) {
459 cleanup_callback_.Run(cert_handle_);
460 cleanup_callback_.Reset();
461 RunCallbacks();
462 delete this;
463 }
464
450 void DiskBasedCertCache::ReadWorker::RunCallbacks() { 465 void DiskBasedCertCache::ReadWorker::RunCallbacks() {
451 for (std::vector<GetCallback>::const_iterator it = user_callbacks_.begin(); 466 for (std::vector<GetCallback>::const_iterator it = user_callbacks_.begin();
452 it != user_callbacks_.end(); 467 it != user_callbacks_.end();
453 ++it) { 468 ++it) {
454 it->Run(cert_handle_); 469 it->Run(cert_handle_);
455 } 470 }
456 user_callbacks_.clear(); 471 user_callbacks_.clear();
457 } 472 }
458 473
459 void DiskBasedCertCache::ReadWorker::Finish(int rv) { 474 void DiskBasedCertCache::CertFree::operator()(
460 cleanup_callback_.Run(); 475 X509Certificate::OSCertHandle cert_handle) {
461 cleanup_callback_.Reset(); 476 X509Certificate::FreeOSCertHandle(cert_handle);
462 RunCallbacks();
463 delete this;
464 }
465
466 void DiskBasedCertCache::ReadWorker::Cancel() {
467 canceled_ = true;
468 }
469
470 DiskBasedCertCache::ReadWorker::~ReadWorker() {
471 if (entry_)
472 entry_->Close();
473 if (cert_handle_)
474 X509Certificate::FreeOSCertHandle(cert_handle_);
475 } 477 }
476 478
477 DiskBasedCertCache::DiskBasedCertCache(disk_cache::Backend* backend) 479 DiskBasedCertCache::DiskBasedCertCache(disk_cache::Backend* backend)
478 : backend_(backend), weak_factory_(this) { 480 : backend_(backend),
481 mru_cert_cache_(kMemoryCacheMaxSize),
482 mem_cache_hits_(0),
483 mem_cache_misses_(0),
484 weak_factory_(this) {
479 DCHECK(backend_); 485 DCHECK(backend_);
480 } 486 }
481 487
482 DiskBasedCertCache::~DiskBasedCertCache() { 488 DiskBasedCertCache::~DiskBasedCertCache() {
483 for (WriteWorkerMap::iterator it = write_worker_map_.begin(); 489 for (WriteWorkerMap::iterator it = write_worker_map_.begin();
484 it != write_worker_map_.end(); 490 it != write_worker_map_.end();
485 ++it) { 491 ++it) {
486 it->second->Cancel(); 492 it->second->Cancel();
487 } 493 }
488 for (ReadWorkerMap::iterator it = read_worker_map_.begin(); 494 for (ReadWorkerMap::iterator it = read_worker_map_.begin();
489 it != read_worker_map_.end(); 495 it != read_worker_map_.end();
490 ++it) { 496 ++it) {
491 it->second->Cancel(); 497 it->second->Cancel();
492 } 498 }
493 } 499 }
494 500
495 void DiskBasedCertCache::Get(const std::string& key, const GetCallback& cb) { 501 void DiskBasedCertCache::Get(const std::string& key, const GetCallback& cb) {
496 DCHECK(!key.empty()); 502 DCHECK(!key.empty());
497 503
504 // If the handle is already in the MRU cache, just return that (via callback).
505 // Note, this will also bring the cert_handle to the front of the recency
506 // list in the MRU cache.
507 MRUCertCache::iterator mru_it = mru_cert_cache_.Get(key);
508 if (mru_it != mru_cert_cache_.end()) {
509 ++mem_cache_hits_;
510 cb.Run(mru_it->second);
511 return;
512 }
513 ++mem_cache_misses_;
514
498 ReadWorkerMap::iterator it = read_worker_map_.find(key); 515 ReadWorkerMap::iterator it = read_worker_map_.find(key);
499 516
500 if (it == read_worker_map_.end()) { 517 if (it == read_worker_map_.end()) {
501 ReadWorker* worker = 518 ReadWorker* worker =
502 new ReadWorker(backend_, 519 new ReadWorker(backend_,
503 key, 520 key,
504 base::Bind(&DiskBasedCertCache::FinishedReadOperation, 521 base::Bind(&DiskBasedCertCache::FinishedReadOperation,
505 weak_factory_.GetWeakPtr(), 522 weak_factory_.GetWeakPtr(),
506 key)); 523 key));
507 read_worker_map_[key] = worker; 524 read_worker_map_[key] = worker;
(...skipping 12 matching lines...) Expand all
520 537
521 WriteWorkerMap::iterator it = write_worker_map_.find(key); 538 WriteWorkerMap::iterator it = write_worker_map_.find(key);
522 539
523 if (it == write_worker_map_.end()) { 540 if (it == write_worker_map_.end()) {
524 WriteWorker* worker = 541 WriteWorker* worker =
525 new WriteWorker(backend_, 542 new WriteWorker(backend_,
526 key, 543 key,
527 cert_handle, 544 cert_handle,
528 base::Bind(&DiskBasedCertCache::FinishedWriteOperation, 545 base::Bind(&DiskBasedCertCache::FinishedWriteOperation,
529 weak_factory_.GetWeakPtr(), 546 weak_factory_.GetWeakPtr(),
530 key)); 547 key,
548 cert_handle));
531 write_worker_map_[key] = worker; 549 write_worker_map_[key] = worker;
532 worker->AddCallback(cb); 550 worker->AddCallback(cb);
533 worker->Start(); 551 worker->Start();
534 } else { 552 } else {
535 it->second->AddCallback(cb); 553 it->second->AddCallback(cb);
536 } 554 }
537 } 555 }
538 556
539 void DiskBasedCertCache::FinishedWriteOperation(const std::string& key) { 557 void DiskBasedCertCache::FinishedReadOperation(
540 write_worker_map_.erase(key); 558 const std::string& key,
541 } 559 X509Certificate::OSCertHandle cert_handle) {
542 560 if (cert_handle)
543 void DiskBasedCertCache::FinishedReadOperation(const std::string& key) { 561 mru_cert_cache_.Put(key, X509Certificate::DupOSCertHandle(cert_handle));
544 read_worker_map_.erase(key); 562 read_worker_map_.erase(key);
545 } 563 }
546 564
565 void DiskBasedCertCache::FinishedWriteOperation(
566 const std::string& key,
567 X509Certificate::OSCertHandle cert_handle) {
568 write_worker_map_.erase(key);
569 if (!key.empty())
570 mru_cert_cache_.Put(key, X509Certificate::DupOSCertHandle(cert_handle));
571 }
572
547 } // namespace net 573 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698