OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/net/quota_policy_channel_id_store.h" | |
6 | |
7 #include <list> | |
8 #include <set> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/bind.h" | |
12 #include "base/file_util.h" | |
13 #include "base/files/file_path.h" | |
14 #include "base/logging.h" | |
15 #include "base/metrics/histogram.h" | |
16 #include "base/strings/string_util.h" | |
17 #include "base/threading/thread.h" | |
18 #include "base/threading/thread_restrictions.h" | |
19 #include "net/cookies/cookie_util.h" | |
20 #include "net/extras/sqlite/sqlite_channel_id_store.h" | |
21 #include "url/gurl.h" | |
22 #include "webkit/browser/quota/special_storage_policy.h" | |
23 | |
24 namespace content { | |
25 | |
26 QuotaPolicyChannelIDStore::QuotaPolicyChannelIDStore( | |
27 const base::FilePath& path, | |
28 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | |
29 quota::SpecialStoragePolicy* special_storage_policy) | |
30 : force_keep_session_state_(false), | |
31 path_(path), | |
32 background_task_runner_(background_task_runner), | |
33 special_storage_policy_(special_storage_policy), | |
34 persistent_(new net::SQLiteChannelIDStore(path, background_task_runner)) { | |
35 DCHECK(background_task_runner); | |
36 } | |
37 | |
38 QuotaPolicyChannelIDStore::~QuotaPolicyChannelIDStore() { | |
39 if (!force_keep_session_state_ && special_storage_policy_.get() && | |
40 special_storage_policy_->HasSessionOnlyOrigins()) { | |
41 persistent_ = NULL; | |
42 scoped_refptr<net::DefaultChannelIDStore::PersistentStore> shutdown_store( | |
43 new net::SQLiteChannelIDStore(path_, background_task_runner_)); | |
44 shutdown_store->Load(base::Bind( | |
45 &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
| |
46 } | |
47 } | |
48 | |
49 void QuotaPolicyChannelIDStore::Load(const LoadedCallback& loaded_callback) { | |
50 persistent_->Load(loaded_callback); | |
51 } | |
52 | |
53 void QuotaPolicyChannelIDStore::AddChannelID( | |
54 const net::DefaultChannelIDStore::ChannelID& channel_id) { | |
55 persistent_->AddChannelID(channel_id); | |
56 } | |
57 | |
58 void QuotaPolicyChannelIDStore::DeleteChannelID( | |
59 const net::DefaultChannelIDStore::ChannelID& channel_id) { | |
60 persistent_->DeleteChannelID(channel_id); | |
61 } | |
62 | |
63 void QuotaPolicyChannelIDStore::SetForceKeepSessionState() { | |
64 force_keep_session_state_ = true; | |
65 } | |
66 | |
67 /* 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.
| |
68 scoped_refptr<net::DefaultChannelIDStore::PersistentStore> shutdown_store, | |
69 quota::SpecialStoragePolicy* special_storage_policy, | |
70 scoped_ptr<ChannelIDVector> channel_ids) { | |
71 DCHECK(special_storage_policy); | |
72 for (ChannelIDVector::const_iterator channel_id = channel_ids->begin(); | |
73 channel_id != channel_ids->end(); | |
74 ++channel_id) { | |
75 const GURL url(net::cookie_util::CookieOriginToURL( | |
76 (*channel_id)->server_identifier(), true)); | |
77 if (special_storage_policy->IsStorageSessionOnly(url)) | |
78 shutdown_store->DeleteChannelID(**channel_id); | |
79 } | |
80 } | |
81 | |
82 } // namespace content | |
OLD | NEW |