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

Side by Side 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: Address review comments. 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 unified diff | Download patch
OLDNEW
(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
9 #include "base/basictypes.h"
10 #include "base/bind.h"
11 #include "base/file_util.h"
12 #include "base/files/file_path.h"
13 #include "base/logging.h"
14 #include "base/metrics/histogram.h"
15 #include "base/strings/string_util.h"
16 #include "base/threading/thread.h"
17 #include "base/threading/thread_restrictions.h"
18 #include "net/cookies/cookie_util.h"
19 #include "net/extras/sqlite/sqlite_channel_id_store.h"
20 #include "url/gurl.h"
21 #include "webkit/browser/quota/special_storage_policy.h"
22
23 namespace content {
24
25 QuotaPolicyChannelIDStore::QuotaPolicyChannelIDStore(
26 const base::FilePath& path,
27 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
28 quota::SpecialStoragePolicy* special_storage_policy)
29 : path_(path),
erikwright (departed) 2014/08/12 20:56:11 why is this member needed?
mef 2014/08/12 21:11:23 Done.
30 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.
31 special_storage_policy_(special_storage_policy),
32 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
33 new net::SQLiteChannelIDStore(path, background_task_runner)) {
34 DCHECK(background_task_runner);
35 }
36
37 QuotaPolicyChannelIDStore::~QuotaPolicyChannelIDStore() {
38 if (special_storage_policy_.get() &&
39 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.
40 std::list<std::string> session_only_server_identifiers;
41 for (std::set<std::string>::iterator it = server_identifiers_.begin();
42 it != server_identifiers_.end();
43 ++it) {
44 GURL url(net::cookie_util::CookieOriginToURL(*it, true));
45 if (special_storage_policy_->IsStorageSessionOnly(url))
46 session_only_server_identifiers.push_back(*it);
47 }
48 persistent_store_->DeleteAllInList(session_only_server_identifiers);
49 }
50 }
51
52 void QuotaPolicyChannelIDStore::Load(const LoadedCallback& loaded_callback) {
53 persistent_store_->Load(
54 base::Bind(&QuotaPolicyChannelIDStore::OnLoad, this, loaded_callback));
55 }
56
57 void QuotaPolicyChannelIDStore::AddChannelID(
58 const net::DefaultChannelIDStore::ChannelID& channel_id) {
59 server_identifiers_.insert(channel_id.server_identifier());
60 persistent_store_->AddChannelID(channel_id);
61 }
62
63 void QuotaPolicyChannelIDStore::DeleteChannelID(
64 const net::DefaultChannelIDStore::ChannelID& channel_id) {
65 server_identifiers_.erase(channel_id.server_identifier());
66 persistent_store_->DeleteChannelID(channel_id);
67 }
68
69 void QuotaPolicyChannelIDStore::SetForceKeepSessionState() {
70 special_storage_policy_ = NULL;
71 }
72
73 void QuotaPolicyChannelIDStore::OnLoad(
74 const LoadedCallback& loaded_callback,
75 scoped_ptr<ChannelIDVector> channel_ids) {
76 for (ChannelIDVector::const_iterator channel_id = channel_ids->begin();
77 channel_id != channel_ids->end();
78 ++channel_id) {
79 server_identifiers_.insert((*channel_id)->server_identifier());
80 }
81 loaded_callback.Run(channel_ids.Pass());
82 }
83
84 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698