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

Side by Side Diff: chrome/browser/net/sqlite_server_bound_cert_store.cc

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged ToT Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/net/sqlite_server_bound_cert_store.h" 5 #include "chrome/browser/net/sqlite_server_bound_cert_store.h"
6 6
7 #include <list> 7 #include <list>
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 BatchOperation(PendingOperation::CERT_DELETE, cert); 472 BatchOperation(PendingOperation::CERT_DELETE, cert);
473 } 473 }
474 474
475 void SQLiteServerBoundCertStore::Backend::BatchOperation( 475 void SQLiteServerBoundCertStore::Backend::BatchOperation(
476 PendingOperation::OperationType op, 476 PendingOperation::OperationType op,
477 const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { 477 const net::DefaultServerBoundCertStore::ServerBoundCert& cert) {
478 // Commit every 30 seconds. 478 // Commit every 30 seconds.
479 static const int kCommitIntervalMs = 30 * 1000; 479 static const int kCommitIntervalMs = 30 * 1000;
480 // Commit right away if we have more than 512 outstanding operations. 480 // Commit right away if we have more than 512 outstanding operations.
481 static const size_t kCommitAfterBatchSize = 512; 481 static const size_t kCommitAfterBatchSize = 512;
482 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::DB));
483 482
484 // We do a full copy of the cert here, and hopefully just here. 483 // We do a full copy of the cert here, and hopefully just here.
485 scoped_ptr<PendingOperation> po(new PendingOperation(op, cert)); 484 scoped_ptr<PendingOperation> po(new PendingOperation(op, cert));
486 485
487 PendingOperationsList::size_type num_pending; 486 PendingOperationsList::size_type num_pending;
488 { 487 {
489 base::AutoLock locked(lock_); 488 base::AutoLock locked(lock_);
490 pending_.push_back(po.release()); 489 pending_.push_back(po.release());
491 num_pending = ++num_pending_; 490 num_pending = ++num_pending_;
492 } 491 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 break; 566 break;
568 } 567 }
569 } 568 }
570 transaction.Commit(); 569 transaction.Commit();
571 } 570 }
572 571
573 // Fire off a close message to the background thread. We could still have a 572 // Fire off a close message to the background thread. We could still have a
574 // pending commit timer that will be holding a reference on us, but if/when 573 // pending commit timer that will be holding a reference on us, but if/when
575 // this fires we will already have been cleaned up and it will be ignored. 574 // this fires we will already have been cleaned up and it will be ignored.
576 void SQLiteServerBoundCertStore::Backend::Close() { 575 void SQLiteServerBoundCertStore::Backend::Close() {
577 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::DB));
578 // Must close the backend on the background thread. 576 // Must close the backend on the background thread.
579 BrowserThread::PostTask( 577 BrowserThread::PostTask(
580 BrowserThread::DB, FROM_HERE, 578 BrowserThread::DB, FROM_HERE,
581 base::Bind(&Backend::InternalBackgroundClose, this)); 579 base::Bind(&Backend::InternalBackgroundClose, this));
582 } 580 }
583 581
584 void SQLiteServerBoundCertStore::Backend::InternalBackgroundClose() { 582 void SQLiteServerBoundCertStore::Backend::InternalBackgroundClose() {
585 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 583 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
586 // Commit any pending operations 584 // Commit any pending operations
587 Commit(); 585 Commit();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 661
664 void SQLiteServerBoundCertStore::SetForceKeepSessionState() { 662 void SQLiteServerBoundCertStore::SetForceKeepSessionState() {
665 backend_->SetForceKeepSessionState(); 663 backend_->SetForceKeepSessionState();
666 } 664 }
667 665
668 SQLiteServerBoundCertStore::~SQLiteServerBoundCertStore() { 666 SQLiteServerBoundCertStore::~SQLiteServerBoundCertStore() {
669 backend_->Close(); 667 backend_->Close();
670 // We release our reference to the Backend, though it will probably still have 668 // We release our reference to the Backend, though it will probably still have
671 // a reference if the background thread has not run Close() yet. 669 // a reference if the background thread has not run Close() yet.
672 } 670 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698