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

Unified Diff: content/browser/net/quota_policy_channel_id_store.cc

Issue 381073002: Move sqlite_channel_id_store from chrome/browser/net to net/extras. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased to r286605 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698