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

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: Rebased to r286605 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 #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 special_storage_policy_(special_storage_policy),
32 persistent_(new net::SQLiteChannelIDStore(path, background_task_runner)),
33 temporary_(new net::SQLiteChannelIDStore(path, background_task_runner)) {
34 }
35
36 QuotaPolicyChannelIDStore::~QuotaPolicyChannelIDStore() {
37 // TODO(mef): delete temporary file.
38 // temporary_.release();
39 }
40
41 void QuotaPolicyChannelIDStore::Load(const LoadedCallback& loaded_callback) {
42 persistent_->Load(loaded_callback);
43 }
44
45 void QuotaPolicyChannelIDStore::AddChannelID(
46 const net::DefaultChannelIDStore::ChannelID& cert) {
47 if (IsStorageSessionOnly(cert)) {
48 temporary_->AddChannelID(cert);
49 } else {
50 persistent_->AddChannelID(cert);
51 }
52 }
53
54 void QuotaPolicyChannelIDStore::DeleteChannelID(
55 const net::DefaultChannelIDStore::ChannelID& cert) {
56 if (IsStorageSessionOnly(cert)) {
57 temporary_->DeleteChannelID(cert);
58 } else {
59 persistent_->DeleteChannelID(cert);
60 }
61 }
62
63 void QuotaPolicyChannelIDStore::SetForceKeepSessionState() {
64 force_keep_session_state_ = true;
65 }
66
67 bool QuotaPolicyChannelIDStore::IsStorageSessionOnly(
68 const net::DefaultChannelIDStore::ChannelID& cert) {
69 if (force_keep_session_state_ || !special_storage_policy_.get())
70 return false;
71 const GURL url(
72 net::cookie_util::CookieOriginToURL(cert.server_identifier(), true));
73 return !url.is_valid() || !special_storage_policy_->IsStorageSessionOnly(url);
74 }
75
76 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698