Chromium Code Reviews| Index: chrome/browser/net/sqlite_channel_id_store.cc |
| diff --git a/chrome/browser/net/sqlite_server_bound_cert_store.cc b/chrome/browser/net/sqlite_channel_id_store.cc |
| similarity index 86% |
| rename from chrome/browser/net/sqlite_server_bound_cert_store.cc |
| rename to chrome/browser/net/sqlite_channel_id_store.cc |
| index fbac4c36d72405ba4183f7446f913c31cc91ff69..44463b6e21c12a8c810d029d50836cc7bcc45ef6 100644 |
| --- a/chrome/browser/net/sqlite_server_bound_cert_store.cc |
| +++ b/chrome/browser/net/sqlite_channel_id_store.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/net/sqlite_server_bound_cert_store.h" |
| +#include "chrome/browser/net/sqlite_channel_id_store.h" |
| #include <list> |
| #include <set> |
| @@ -30,8 +30,8 @@ |
| // This class is designed to be shared between any calling threads and the |
| // background task runner. It batches operations and commits them on a timer. |
| -class SQLiteServerBoundCertStore::Backend |
| - : public base::RefCountedThreadSafe<SQLiteServerBoundCertStore::Backend> { |
| +class SQLiteChannelIDStore::Backend |
| + : public base::RefCountedThreadSafe<SQLiteChannelIDStore::Backend> { |
| public: |
| Backend( |
| const base::FilePath& path, |
| @@ -48,12 +48,12 @@ class SQLiteServerBoundCertStore::Backend |
| void Load(const LoadedCallback& loaded_callback); |
| // Batch a server bound cert addition. |
|
wtc
2014/07/01 19:50:50
server bound cert => channel ID
Also fix line 54
Ryan Hamilton
2014/07/21 19:12:07
Done.
|
| - void AddServerBoundCert( |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert); |
| + void AddChannelID( |
| + const net::DefaultChannelIDStore::ChannelID& cert); |
| // Batch a server bound cert deletion. |
| - void DeleteServerBoundCert( |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert); |
| + void DeleteChannelID( |
| + const net::DefaultChannelIDStore::ChannelID& cert); |
|
wtc
2014/07/01 19:50:50
cert => channel_id
in these two methods.
Ryan Hamilton
2014/07/21 19:12:06
Done.
|
| // Commit any pending operations and close the database. This must be called |
| // before the object is destructed. |
| @@ -63,9 +63,9 @@ class SQLiteServerBoundCertStore::Backend |
| private: |
| void LoadOnDBThread( |
| - ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert>* certs); |
| + ScopedVector<net::DefaultChannelIDStore::ChannelID>* certs); |
|
wtc
2014/07/01 19:50:50
certs => channel_ids
Ryan Hamilton
2014/07/21 19:12:06
Done.
|
| - friend class base::RefCountedThreadSafe<SQLiteServerBoundCertStore::Backend>; |
| + friend class base::RefCountedThreadSafe<SQLiteChannelIDStore::Backend>; |
| // You should call Close() before destructing this object. |
| ~Backend() { |
| @@ -85,24 +85,24 @@ class SQLiteServerBoundCertStore::Backend |
| PendingOperation( |
| OperationType op, |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert) |
| + const net::DefaultChannelIDStore::ChannelID& cert) |
|
wtc
2014/07/01 19:50:51
cert => channel_id
Ryan Hamilton
2014/07/21 19:12:06
Done.
|
| : op_(op), cert_(cert) {} |
| OperationType op() const { return op_; } |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert() const { |
| + const net::DefaultChannelIDStore::ChannelID& cert() const { |
|
wtc
2014/07/01 19:50:50
cert() => channel_id()
Ryan Hamilton
2014/07/21 19:12:06
Done.
|
| return cert_; |
| } |
| private: |
| OperationType op_; |
| - net::DefaultServerBoundCertStore::ServerBoundCert cert_; |
| + net::DefaultChannelIDStore::ChannelID cert_; |
|
wtc
2014/07/01 19:50:50
cert_ => channel_id_
Ryan Hamilton
2014/07/21 19:12:06
Done.
|
| }; |
| private: |
| // Batch a server bound cert operation (add or delete). |
| void BatchOperation( |
| PendingOperation::OperationType op, |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert); |
| + const net::DefaultChannelIDStore::ChannelID& cert); |
|
wtc
2014/07/01 19:50:51
cert => channel_id
Ryan Hamilton
2014/07/21 19:12:06
Done.
|
| // Commit our pending operations to the database. |
| void Commit(); |
| // Close() executed on the background thread. |
| @@ -147,7 +147,7 @@ namespace { |
| // Initializes the certs table, returning true on success. |
| bool InitTable(sql::Connection* db) { |
| // The table is named "origin_bound_certs" for backwards compatability before |
| - // we renamed this class to SQLiteServerBoundCertStore. Likewise, the primary |
| + // we renamed this class to SQLiteChannelIDStore. Likewise, the primary |
| // key is "origin", but now can be other things like a plain domain. |
| if (!db->DoesTableExist("origin_bound_certs")) { |
| if (!db->Execute("CREATE TABLE origin_bound_certs (" |
| @@ -165,14 +165,14 @@ bool InitTable(sql::Connection* db) { |
| } // namespace |
| -void SQLiteServerBoundCertStore::Backend::Load( |
| +void SQLiteChannelIDStore::Backend::Load( |
| const LoadedCallback& loaded_callback) { |
| // This function should be called only once per instance. |
| DCHECK(!db_.get()); |
| - scoped_ptr<ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> > |
| - certs(new ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert>( |
| + scoped_ptr<ScopedVector<net::DefaultChannelIDStore::ChannelID> > |
| + certs(new ScopedVector<net::DefaultChannelIDStore::ChannelID>( |
| )); |
| - ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert>* certs_ptr = |
| + ScopedVector<net::DefaultChannelIDStore::ChannelID>* certs_ptr = |
|
wtc
2014/07/01 19:50:50
certs_ptr => channel_ids_ptr
Ryan Hamilton
2014/07/21 19:12:07
Done.
|
| certs.get(); |
| background_task_runner_->PostTaskAndReply( |
| @@ -181,8 +181,8 @@ void SQLiteServerBoundCertStore::Backend::Load( |
| base::Bind(loaded_callback, base::Passed(&certs))); |
| } |
| -void SQLiteServerBoundCertStore::Backend::LoadOnDBThread( |
| - ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert>* certs) { |
| +void SQLiteChannelIDStore::Backend::LoadOnDBThread( |
| + ScopedVector<net::DefaultChannelIDStore::ChannelID>* certs) { |
|
wtc
2014/07/01 19:50:50
certs => channel_ids
Ryan Hamilton
2014/07/21 19:12:06
Done.
|
| DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| // This method should be called only once per instance. |
| @@ -205,7 +205,7 @@ void SQLiteServerBoundCertStore::Backend::LoadOnDBThread( |
| // Unretained to avoid a ref loop with db_. |
| db_->set_error_callback( |
| - base::Bind(&SQLiteServerBoundCertStore::Backend::DatabaseErrorCallback, |
| + base::Bind(&SQLiteChannelIDStore::Backend::DatabaseErrorCallback, |
| base::Unretained(this))); |
| if (!db_->Open(path_)) { |
| @@ -247,8 +247,8 @@ void SQLiteServerBoundCertStore::Backend::LoadOnDBThread( |
| std::string private_key_from_db, cert_from_db; |
| smt.ColumnBlobAsString(1, &private_key_from_db); |
| smt.ColumnBlobAsString(2, &cert_from_db); |
| - scoped_ptr<net::DefaultServerBoundCertStore::ServerBoundCert> cert( |
| - new net::DefaultServerBoundCertStore::ServerBoundCert( |
| + scoped_ptr<net::DefaultChannelIDStore::ChannelID> cert( |
|
wtc
2014/07/01 19:50:50
cert => channel_id
Ryan Hamilton
2014/07/21 19:12:07
Done.
|
| + new net::DefaultChannelIDStore::ChannelID( |
| smt.ColumnString(0), // origin |
| base::Time::FromInternalValue(smt.ColumnInt64(5)), |
| base::Time::FromInternalValue(smt.ColumnInt64(4)), |
| @@ -269,7 +269,7 @@ void SQLiteServerBoundCertStore::Backend::LoadOnDBThread( |
| << " ms"; |
| } |
| -bool SQLiteServerBoundCertStore::Backend::EnsureDatabaseVersion() { |
| +bool SQLiteChannelIDStore::Backend::EnsureDatabaseVersion() { |
| // Version check. |
| if (!meta_table_.Init( |
| db_.get(), kCurrentVersionNumber, kCompatibleVersionNumber)) { |
| @@ -396,7 +396,7 @@ bool SQLiteServerBoundCertStore::Backend::EnsureDatabaseVersion() { |
| return true; |
| } |
| -void SQLiteServerBoundCertStore::Backend::DatabaseErrorCallback( |
| +void SQLiteChannelIDStore::Backend::DatabaseErrorCallback( |
| int error, |
| sql::Statement* stmt) { |
| DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| @@ -418,7 +418,7 @@ void SQLiteServerBoundCertStore::Backend::DatabaseErrorCallback( |
| base::Bind(&Backend::KillDatabase, this)); |
| } |
| -void SQLiteServerBoundCertStore::Backend::KillDatabase() { |
| +void SQLiteChannelIDStore::Backend::KillDatabase() { |
| DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| if (db_) { |
| @@ -431,19 +431,19 @@ void SQLiteServerBoundCertStore::Backend::KillDatabase() { |
| } |
| } |
| -void SQLiteServerBoundCertStore::Backend::AddServerBoundCert( |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| +void SQLiteChannelIDStore::Backend::AddChannelID( |
| + const net::DefaultChannelIDStore::ChannelID& cert) { |
| BatchOperation(PendingOperation::CERT_ADD, cert); |
| } |
| -void SQLiteServerBoundCertStore::Backend::DeleteServerBoundCert( |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| +void SQLiteChannelIDStore::Backend::DeleteChannelID( |
| + const net::DefaultChannelIDStore::ChannelID& cert) { |
| BatchOperation(PendingOperation::CERT_DELETE, cert); |
| } |
| -void SQLiteServerBoundCertStore::Backend::BatchOperation( |
| +void SQLiteChannelIDStore::Backend::BatchOperation( |
| PendingOperation::OperationType op, |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| + const net::DefaultChannelIDStore::ChannelID& cert) { |
|
wtc
2014/07/01 19:50:50
cert => channel_id
in these three methods.
Ryan Hamilton
2014/07/21 19:12:06
Done.
|
| // Commit every 30 seconds. |
| static const int kCommitIntervalMs = 30 * 1000; |
| // Commit right away if we have more than 512 outstanding operations. |
| @@ -472,7 +472,7 @@ void SQLiteServerBoundCertStore::Backend::BatchOperation( |
| } |
| } |
| -void SQLiteServerBoundCertStore::Backend::Commit() { |
| +void SQLiteChannelIDStore::Backend::Commit() { |
| DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| PendingOperationsList ops; |
| @@ -540,13 +540,13 @@ void SQLiteServerBoundCertStore::Backend::Commit() { |
| // Fire off a close message to the background thread. We could still have a |
| // pending commit timer that will be holding a reference on us, but if/when |
| // this fires we will already have been cleaned up and it will be ignored. |
| -void SQLiteServerBoundCertStore::Backend::Close() { |
| +void SQLiteChannelIDStore::Backend::Close() { |
| // Must close the backend on the background thread. |
| background_task_runner_->PostTask( |
| FROM_HERE, base::Bind(&Backend::InternalBackgroundClose, this)); |
| } |
| -void SQLiteServerBoundCertStore::Backend::InternalBackgroundClose() { |
| +void SQLiteChannelIDStore::Backend::InternalBackgroundClose() { |
| DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| // Commit any pending operations |
| Commit(); |
| @@ -560,7 +560,7 @@ void SQLiteServerBoundCertStore::Backend::InternalBackgroundClose() { |
| db_.reset(); |
| } |
| -void SQLiteServerBoundCertStore::Backend::DeleteCertificatesOnShutdown() { |
| +void SQLiteChannelIDStore::Backend::DeleteCertificatesOnShutdown() { |
| DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| if (!db_.get()) |
| @@ -600,12 +600,12 @@ void SQLiteServerBoundCertStore::Backend::DeleteCertificatesOnShutdown() { |
| LOG(WARNING) << "Unable to delete certificates on shutdown."; |
| } |
| -void SQLiteServerBoundCertStore::Backend::SetForceKeepSessionState() { |
| +void SQLiteChannelIDStore::Backend::SetForceKeepSessionState() { |
| base::AutoLock locked(lock_); |
| force_keep_session_state_ = true; |
| } |
| -SQLiteServerBoundCertStore::SQLiteServerBoundCertStore( |
| +SQLiteChannelIDStore::SQLiteChannelIDStore( |
| const base::FilePath& path, |
| const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| quota::SpecialStoragePolicy* special_storage_policy) |
| @@ -613,26 +613,26 @@ SQLiteServerBoundCertStore::SQLiteServerBoundCertStore( |
| background_task_runner, |
| special_storage_policy)) {} |
| -void SQLiteServerBoundCertStore::Load( |
| +void SQLiteChannelIDStore::Load( |
| const LoadedCallback& loaded_callback) { |
| backend_->Load(loaded_callback); |
| } |
| -void SQLiteServerBoundCertStore::AddServerBoundCert( |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| - backend_->AddServerBoundCert(cert); |
| +void SQLiteChannelIDStore::AddChannelID( |
| + const net::DefaultChannelIDStore::ChannelID& cert) { |
| + backend_->AddChannelID(cert); |
| } |
| -void SQLiteServerBoundCertStore::DeleteServerBoundCert( |
| - const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| - backend_->DeleteServerBoundCert(cert); |
| +void SQLiteChannelIDStore::DeleteChannelID( |
| + const net::DefaultChannelIDStore::ChannelID& cert) { |
|
wtc
2014/07/01 19:50:51
cert => channel_id
in these two methods.
Ryan Hamilton
2014/07/21 19:12:06
Done.
|
| + backend_->DeleteChannelID(cert); |
| } |
| -void SQLiteServerBoundCertStore::SetForceKeepSessionState() { |
| +void SQLiteChannelIDStore::SetForceKeepSessionState() { |
| backend_->SetForceKeepSessionState(); |
| } |
| -SQLiteServerBoundCertStore::~SQLiteServerBoundCertStore() { |
| +SQLiteChannelIDStore::~SQLiteChannelIDStore() { |
| backend_->Close(); |
| // We release our reference to the Backend, though it will probably still have |
| // a reference if the background thread has not run Close() yet. |