Index: content/browser/net/quota_policy_channel_id_store.cc |
diff --git a/content/browser/net/quota_policy_channel_id_store.cc b/content/browser/net/quota_policy_channel_id_store.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..108def479b3622426d8862fb051d1184f3a5537f |
--- /dev/null |
+++ b/content/browser/net/quota_policy_channel_id_store.cc |
@@ -0,0 +1,76 @@ |
+// 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_channel_id_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/extras/sqlite/sqlite_channel_id_store.h" |
+#include "url/gurl.h" |
+#include "webkit/browser/quota/special_storage_policy.h" |
+ |
+namespace content { |
+ |
+QuotaPolicyChannelIDStore::QuotaPolicyChannelIDStore( |
+ 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::SQLiteChannelIDStore(path, background_task_runner)), |
+ temporary_(new net::SQLiteChannelIDStore(path, background_task_runner)) { |
+} |
+ |
+QuotaPolicyChannelIDStore::~QuotaPolicyChannelIDStore() { |
+ // TODO(mef): delete temporary file. |
+ // temporary_.release(); |
+} |
+ |
+void QuotaPolicyChannelIDStore::Load(const LoadedCallback& loaded_callback) { |
+ persistent_->Load(loaded_callback); |
+} |
+ |
+void QuotaPolicyChannelIDStore::AddChannelID( |
+ const net::DefaultChannelIDStore::ChannelID& cert) { |
+ if (IsStorageSessionOnly(cert)) { |
+ temporary_->AddChannelID(cert); |
+ } else { |
+ persistent_->AddChannelID(cert); |
+ } |
+} |
+ |
+void QuotaPolicyChannelIDStore::DeleteChannelID( |
+ const net::DefaultChannelIDStore::ChannelID& cert) { |
+ if (IsStorageSessionOnly(cert)) { |
+ temporary_->DeleteChannelID(cert); |
+ } else { |
+ persistent_->DeleteChannelID(cert); |
+ } |
+} |
+ |
+void QuotaPolicyChannelIDStore::SetForceKeepSessionState() { |
+ force_keep_session_state_ = true; |
+} |
+ |
+bool QuotaPolicyChannelIDStore::IsStorageSessionOnly( |
+ const net::DefaultChannelIDStore::ChannelID& 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); |
+} |
+ |
+} // namespace content |