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..eb713e050a3fb41cee3511e1cf86030e255e1da1 |
--- /dev/null |
+++ b/content/browser/net/quota_policy_channel_id_store.cc |
@@ -0,0 +1,82 @@ |
+// 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), |
+ path_(path), |
+ background_task_runner_(background_task_runner), |
+ special_storage_policy_(special_storage_policy), |
+ persistent_(new net::SQLiteChannelIDStore(path, background_task_runner)) { |
+ DCHECK(background_task_runner); |
+} |
+ |
+QuotaPolicyChannelIDStore::~QuotaPolicyChannelIDStore() { |
+ if (!force_keep_session_state_ && special_storage_policy_.get() && |
+ special_storage_policy_->HasSessionOnlyOrigins()) { |
+ persistent_ = NULL; |
+ scoped_refptr<net::DefaultChannelIDStore::PersistentStore> shutdown_store( |
+ new net::SQLiteChannelIDStore(path_, background_task_runner_)); |
+ shutdown_store->Load(base::Bind( |
+ &ApplyPolicyOnShutdown, shutdown_store, special_storage_policy_)); |
Ryan Sleevi
2014/08/06 22:39:58
Doesn't this create a race condition?
That is:
{
mef
2014/08/07 17:40:58
Yeah, you are right. In current SQLiteChannelIDSto
|
+ } |
+} |
+ |
+void QuotaPolicyChannelIDStore::Load(const LoadedCallback& loaded_callback) { |
+ persistent_->Load(loaded_callback); |
+} |
+ |
+void QuotaPolicyChannelIDStore::AddChannelID( |
+ const net::DefaultChannelIDStore::ChannelID& channel_id) { |
+ persistent_->AddChannelID(channel_id); |
+} |
+ |
+void QuotaPolicyChannelIDStore::DeleteChannelID( |
+ const net::DefaultChannelIDStore::ChannelID& channel_id) { |
+ persistent_->DeleteChannelID(channel_id); |
+} |
+ |
+void QuotaPolicyChannelIDStore::SetForceKeepSessionState() { |
+ force_keep_session_state_ = true; |
+} |
+ |
+/* static */ void QuotaPolicyChannelIDStore::ApplyPolicyOnShutdown( |
Ryan Sleevi
2014/08/06 22:39:58
Delete the /* static */
Chromium style is typical
mef
2014/08/07 17:40:58
Done.
|
+ scoped_refptr<net::DefaultChannelIDStore::PersistentStore> shutdown_store, |
+ quota::SpecialStoragePolicy* special_storage_policy, |
+ scoped_ptr<ChannelIDVector> channel_ids) { |
+ DCHECK(special_storage_policy); |
+ for (ChannelIDVector::const_iterator channel_id = channel_ids->begin(); |
+ channel_id != channel_ids->end(); |
+ ++channel_id) { |
+ const GURL url(net::cookie_util::CookieOriginToURL( |
+ (*channel_id)->server_identifier(), true)); |
+ if (special_storage_policy->IsStorageSessionOnly(url)) |
+ shutdown_store->DeleteChannelID(**channel_id); |
+ } |
+} |
+ |
+} // namespace content |