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..c0ec58362f1f7a652d058f30103eef0eba4e3025 |
--- /dev/null |
+++ b/content/browser/net/quota_policy_channel_id_store.cc |
@@ -0,0 +1,84 @@ |
+// 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 "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) |
+ : path_(path), |
erikwright (departed)
2014/08/12 20:56:11
why is this member needed?
mef
2014/08/12 21:11:23
Done.
|
+ background_task_runner_(background_task_runner), |
erikwright (departed)
2014/08/12 20:56:12
also not needed
mef
2014/08/12 21:11:23
Done.
|
+ special_storage_policy_(special_storage_policy), |
+ persistent_store_( |
erikwright (departed)
2014/08/12 20:56:12
Consider accepting a DefaultChannelIDStore::Persis
mef
2014/08/12 21:11:22
Ack. The patchset #17 (https://codereview.chromium
erikwright (departed)
2014/08/13 15:49:09
It's your choice. I think you will remove dozens o
|
+ new net::SQLiteChannelIDStore(path, background_task_runner)) { |
+ DCHECK(background_task_runner); |
+} |
+ |
+QuotaPolicyChannelIDStore::~QuotaPolicyChannelIDStore() { |
+ if (special_storage_policy_.get() && |
+ special_storage_policy_->HasSessionOnlyOrigins()) { |
erikwright (departed)
2014/08/12 20:56:12
consider reversing the logic and returning early i
mef
2014/08/12 21:11:22
Done.
|
+ 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()); |
+} |
+ |
+} // namespace content |