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

Unified Diff: chrome/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: Fix flaky TestDeleteAll. Created 6 years, 4 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: chrome/browser/net/quota_policy_channel_id_store.cc
diff --git a/chrome/browser/net/quota_policy_channel_id_store.cc b/chrome/browser/net/quota_policy_channel_id_store.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c88d979505911a387138e0962f9938d7fd5e9de6
--- /dev/null
+++ b/chrome/browser/net/quota_policy_channel_id_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 "chrome/browser/net/quota_policy_channel_id_store.h"
+
+#include <list>
+
+#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"
+
+QuotaPolicyChannelIDStore::QuotaPolicyChannelIDStore(
+ const base::FilePath& path,
+ const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
+ storage::SpecialStoragePolicy* special_storage_policy)
+ : special_storage_policy_(special_storage_policy),
+ persistent_store_(
+ new net::SQLiteChannelIDStore(path, background_task_runner)) {
+ DCHECK(background_task_runner);
+}
+
+QuotaPolicyChannelIDStore::~QuotaPolicyChannelIDStore() {
+ if (!special_storage_policy_.get() ||
+ !special_storage_policy_->HasSessionOnlyOrigins()) {
+ return;
+ }
+ std::list<std::string> session_only_server_identifiers;
+ for (std::set<std::string>::iterator it = server_identifiers_.begin();
+ it != server_identifiers_.end();
+ ++it) {
+ GURL url(net::cookie_util::CookieOriginToURL(*it, true));
+ if (special_storage_policy_->IsStorageSessionOnly(url))
+ session_only_server_identifiers.push_back(*it);
+ }
+ persistent_store_->DeleteAllInList(session_only_server_identifiers);
+}
+
+void QuotaPolicyChannelIDStore::Load(const LoadedCallback& loaded_callback) {
+ persistent_store_->Load(
+ base::Bind(&QuotaPolicyChannelIDStore::OnLoad, this, loaded_callback));
+}
+
+void QuotaPolicyChannelIDStore::AddChannelID(
+ const net::DefaultChannelIDStore::ChannelID& channel_id) {
+ server_identifiers_.insert(channel_id.server_identifier());
+ persistent_store_->AddChannelID(channel_id);
+}
+
+void QuotaPolicyChannelIDStore::DeleteChannelID(
+ const net::DefaultChannelIDStore::ChannelID& channel_id) {
+ server_identifiers_.erase(channel_id.server_identifier());
+ persistent_store_->DeleteChannelID(channel_id);
+}
+
+void QuotaPolicyChannelIDStore::SetForceKeepSessionState() {
+ special_storage_policy_ = NULL;
+}
+
+void QuotaPolicyChannelIDStore::OnLoad(
+ const LoadedCallback& loaded_callback,
+ scoped_ptr<ChannelIDVector> channel_ids) {
+ for (ChannelIDVector::const_iterator channel_id = channel_ids->begin();
+ channel_id != channel_ids->end();
+ ++channel_id) {
+ server_identifiers_.insert((*channel_id)->server_identifier());
+ }
+ loaded_callback.Run(channel_ids.Pass());
+}
« no previous file with comments | « chrome/browser/net/quota_policy_channel_id_store.h ('k') | chrome/browser/net/quota_policy_channel_id_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698