Chromium Code Reviews| Index: content/browser/net/quota_policy_server_bound_cert_store.cc |
| diff --git a/content/browser/net/quota_policy_server_bound_cert_store.cc b/content/browser/net/quota_policy_server_bound_cert_store.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..33ef89d6382e41f0e972aec5acdb21c881ef7e50 |
| --- /dev/null |
| +++ b/content/browser/net/quota_policy_server_bound_cert_store.cc |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/net/quota_policy_server_bound_cert_store.h" |
| + |
| +#include <list> |
| +#include <set> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/bind.h" |
| +#include "base/file_util.h" |
| +#include "base/files/file_path.h" |
| +#include "base/logging.h" |
| +#include "base/metrics/histogram.h" |
| +#include "base/strings/string_util.h" |
| +#include "base/threading/thread.h" |
| +#include "base/threading/thread_restrictions.h" |
| +#include "net/cookies/cookie_util.h" |
| +#include "net/util/sqlite/sqlite_server_bound_cert_store.h" |
| +#include "url/gurl.h" |
| +#include "webkit/browser/quota/special_storage_policy.h" |
| + |
| +namespace content { |
| + |
| +QuotaPolicyServerBoundCertStore::QuotaPolicyServerBoundCertStore( |
| + const base::FilePath& path, |
| + const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, |
| + quota::SpecialStoragePolicy* special_storage_policy) |
| + : force_keep_session_state_(false), |
| + special_storage_policy_(special_storage_policy), |
| + persistent_( |
| + new net::SQLiteServerBoundCertStore(path, background_task_runner)), |
| + temporary_( |
| + new net::SQLiteServerBoundCertStore(path, background_task_runner)) { |
| +} |
| + |
| +QuotaPolicyServerBoundCertStore::~QuotaPolicyServerBoundCertStore() { |
| + // TODO(mef): delete temporary file. |
| + // temporary_.release(); |
| +} |
| + |
| +void QuotaPolicyServerBoundCertStore::Load( |
| + const LoadedCallback& loaded_callback) { |
| + persistent_->Load(loaded_callback); |
| +} |
| + |
| +void QuotaPolicyServerBoundCertStore::AddServerBoundCert( |
| + const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| + if (IsStorageSessionOnly(cert)) { |
| + temporary_->AddServerBoundCert(cert); |
| + } else { |
| + persistent_->AddServerBoundCert(cert); |
| + } |
| +} |
| + |
| +void QuotaPolicyServerBoundCertStore::DeleteServerBoundCert( |
| + const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| + if (IsStorageSessionOnly(cert)) { |
| + temporary_->DeleteServerBoundCert(cert); |
| + } else { |
| + persistent_->DeleteServerBoundCert(cert); |
| + } |
| +} |
| + |
| +void QuotaPolicyServerBoundCertStore::SetForceKeepSessionState() { |
| + force_keep_session_state_ = true; |
| +} |
| + |
| +bool QuotaPolicyServerBoundCertStore::IsStorageSessionOnly( |
| + const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { |
| + if (force_keep_session_state_ || !special_storage_policy_.get()) |
| + return false; |
| + const GURL url( |
| + net::cookie_util::CookieOriginToURL(cert.server_identifier(), true)); |
| + return !url.is_valid() || !special_storage_policy_->IsStorageSessionOnly(url); |
|
Ryan Sleevi
2014/07/24 23:47:32
What about certs that the ssp decides later are Is
mef
2014/07/30 22:12:05
Good question, I actually don't know.
I imagine t
|
| +} |
| + |
| +} // namespace content |