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

Side by Side Diff: content/browser/indexed_db/indexed_db_quota_client.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/indexed_db/indexed_db_quota_client.h" 5 #include "content/browser/indexed_db/indexed_db_quota_client.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/indexed_db/indexed_db_context_impl.h" 10 #include "content/browser/indexed_db/indexed_db_context_impl.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
13 #include "webkit/browser/database/database_util.h" 13 #include "webkit/browser/database/database_util.h"
14 14
15 using quota::QuotaClient; 15 using storage::QuotaClient;
16 using webkit_database::DatabaseUtil; 16 using storage::DatabaseUtil;
17 17
18 namespace content { 18 namespace content {
19 namespace { 19 namespace {
20 20
21 quota::QuotaStatusCode DeleteOriginDataOnIndexedDBThread( 21 storage::QuotaStatusCode DeleteOriginDataOnIndexedDBThread(
22 IndexedDBContextImpl* context, 22 IndexedDBContextImpl* context,
23 const GURL& origin) { 23 const GURL& origin) {
24 context->DeleteForOrigin(origin); 24 context->DeleteForOrigin(origin);
25 return quota::kQuotaStatusOk; 25 return storage::kQuotaStatusOk;
26 } 26 }
27 27
28 int64 GetOriginUsageOnIndexedDBThread(IndexedDBContextImpl* context, 28 int64 GetOriginUsageOnIndexedDBThread(IndexedDBContextImpl* context,
29 const GURL& origin) { 29 const GURL& origin) {
30 DCHECK(context->TaskRunner()->RunsTasksOnCurrentThread()); 30 DCHECK(context->TaskRunner()->RunsTasksOnCurrentThread());
31 return context->GetOriginDiskUsage(origin); 31 return context->GetOriginDiskUsage(origin);
32 } 32 }
33 33
34 void GetAllOriginsOnIndexedDBThread(IndexedDBContextImpl* context, 34 void GetAllOriginsOnIndexedDBThread(IndexedDBContextImpl* context,
35 std::set<GURL>* origins_to_return) { 35 std::set<GURL>* origins_to_return) {
(...skipping 29 matching lines...) Expand all
65 IndexedDBContextImpl* indexed_db_context) 65 IndexedDBContextImpl* indexed_db_context)
66 : indexed_db_context_(indexed_db_context) {} 66 : indexed_db_context_(indexed_db_context) {}
67 67
68 IndexedDBQuotaClient::~IndexedDBQuotaClient() {} 68 IndexedDBQuotaClient::~IndexedDBQuotaClient() {}
69 69
70 QuotaClient::ID IndexedDBQuotaClient::id() const { return kIndexedDatabase; } 70 QuotaClient::ID IndexedDBQuotaClient::id() const { return kIndexedDatabase; }
71 71
72 void IndexedDBQuotaClient::OnQuotaManagerDestroyed() { delete this; } 72 void IndexedDBQuotaClient::OnQuotaManagerDestroyed() { delete this; }
73 73
74 void IndexedDBQuotaClient::GetOriginUsage(const GURL& origin_url, 74 void IndexedDBQuotaClient::GetOriginUsage(const GURL& origin_url,
75 quota::StorageType type, 75 storage::StorageType type,
76 const GetUsageCallback& callback) { 76 const GetUsageCallback& callback) {
77 DCHECK(!callback.is_null()); 77 DCHECK(!callback.is_null());
78 DCHECK(indexed_db_context_); 78 DCHECK(indexed_db_context_);
79 79
80 // IndexedDB is in the temp namespace for now. 80 // IndexedDB is in the temp namespace for now.
81 if (type != quota::kStorageTypeTemporary) { 81 if (type != storage::kStorageTypeTemporary) {
82 callback.Run(0); 82 callback.Run(0);
83 return; 83 return;
84 } 84 }
85 85
86 // No task runner means unit test; no cleanup necessary. 86 // No task runner means unit test; no cleanup necessary.
87 if (!indexed_db_context_->TaskRunner()) { 87 if (!indexed_db_context_->TaskRunner()) {
88 callback.Run(0); 88 callback.Run(0);
89 return; 89 return;
90 } 90 }
91 91
92 base::PostTaskAndReplyWithResult( 92 base::PostTaskAndReplyWithResult(
93 indexed_db_context_->TaskRunner(), 93 indexed_db_context_->TaskRunner(),
94 FROM_HERE, 94 FROM_HERE,
95 base::Bind( 95 base::Bind(
96 &GetOriginUsageOnIndexedDBThread, indexed_db_context_, origin_url), 96 &GetOriginUsageOnIndexedDBThread, indexed_db_context_, origin_url),
97 callback); 97 callback);
98 } 98 }
99 99
100 void IndexedDBQuotaClient::GetOriginsForType( 100 void IndexedDBQuotaClient::GetOriginsForType(
101 quota::StorageType type, 101 storage::StorageType type,
102 const GetOriginsCallback& callback) { 102 const GetOriginsCallback& callback) {
103 DCHECK(!callback.is_null()); 103 DCHECK(!callback.is_null());
104 DCHECK(indexed_db_context_); 104 DCHECK(indexed_db_context_);
105 105
106 // All databases are in the temp namespace for now. 106 // All databases are in the temp namespace for now.
107 if (type != quota::kStorageTypeTemporary) { 107 if (type != storage::kStorageTypeTemporary) {
108 callback.Run(std::set<GURL>()); 108 callback.Run(std::set<GURL>());
109 return; 109 return;
110 } 110 }
111 111
112 // No task runner means unit test; no cleanup necessary. 112 // No task runner means unit test; no cleanup necessary.
113 if (!indexed_db_context_->TaskRunner()) { 113 if (!indexed_db_context_->TaskRunner()) {
114 callback.Run(std::set<GURL>()); 114 callback.Run(std::set<GURL>());
115 return; 115 return;
116 } 116 }
117 117
118 std::set<GURL>* origins_to_return = new std::set<GURL>(); 118 std::set<GURL>* origins_to_return = new std::set<GURL>();
119 indexed_db_context_->TaskRunner()->PostTaskAndReply( 119 indexed_db_context_->TaskRunner()->PostTaskAndReply(
120 FROM_HERE, 120 FROM_HERE,
121 base::Bind(&GetAllOriginsOnIndexedDBThread, 121 base::Bind(&GetAllOriginsOnIndexedDBThread,
122 indexed_db_context_, 122 indexed_db_context_,
123 base::Unretained(origins_to_return)), 123 base::Unretained(origins_to_return)),
124 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); 124 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return)));
125 } 125 }
126 126
127 void IndexedDBQuotaClient::GetOriginsForHost( 127 void IndexedDBQuotaClient::GetOriginsForHost(
128 quota::StorageType type, 128 storage::StorageType type,
129 const std::string& host, 129 const std::string& host,
130 const GetOriginsCallback& callback) { 130 const GetOriginsCallback& callback) {
131 DCHECK(!callback.is_null()); 131 DCHECK(!callback.is_null());
132 DCHECK(indexed_db_context_); 132 DCHECK(indexed_db_context_);
133 133
134 // All databases are in the temp namespace for now. 134 // All databases are in the temp namespace for now.
135 if (type != quota::kStorageTypeTemporary) { 135 if (type != storage::kStorageTypeTemporary) {
136 callback.Run(std::set<GURL>()); 136 callback.Run(std::set<GURL>());
137 return; 137 return;
138 } 138 }
139 139
140 // No task runner means unit test; no cleanup necessary. 140 // No task runner means unit test; no cleanup necessary.
141 if (!indexed_db_context_->TaskRunner()) { 141 if (!indexed_db_context_->TaskRunner()) {
142 callback.Run(std::set<GURL>()); 142 callback.Run(std::set<GURL>());
143 return; 143 return;
144 } 144 }
145 145
146 std::set<GURL>* origins_to_return = new std::set<GURL>(); 146 std::set<GURL>* origins_to_return = new std::set<GURL>();
147 indexed_db_context_->TaskRunner()->PostTaskAndReply( 147 indexed_db_context_->TaskRunner()->PostTaskAndReply(
148 FROM_HERE, 148 FROM_HERE,
149 base::Bind(&GetOriginsForHostOnIndexedDBThread, 149 base::Bind(&GetOriginsForHostOnIndexedDBThread,
150 indexed_db_context_, 150 indexed_db_context_,
151 host, 151 host,
152 base::Unretained(origins_to_return)), 152 base::Unretained(origins_to_return)),
153 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); 153 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return)));
154 } 154 }
155 155
156 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin, 156 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin,
157 quota::StorageType type, 157 storage::StorageType type,
158 const DeletionCallback& callback) { 158 const DeletionCallback& callback) {
159 if (type != quota::kStorageTypeTemporary) { 159 if (type != storage::kStorageTypeTemporary) {
160 callback.Run(quota::kQuotaErrorNotSupported); 160 callback.Run(storage::kQuotaErrorNotSupported);
161 return; 161 return;
162 } 162 }
163 163
164 // No task runner means unit test; no cleanup necessary. 164 // No task runner means unit test; no cleanup necessary.
165 if (!indexed_db_context_->TaskRunner()) { 165 if (!indexed_db_context_->TaskRunner()) {
166 callback.Run(quota::kQuotaStatusOk); 166 callback.Run(storage::kQuotaStatusOk);
167 return; 167 return;
168 } 168 }
169 169
170 base::PostTaskAndReplyWithResult( 170 base::PostTaskAndReplyWithResult(
171 indexed_db_context_->TaskRunner(), 171 indexed_db_context_->TaskRunner(),
172 FROM_HERE, 172 FROM_HERE,
173 base::Bind( 173 base::Bind(
174 &DeleteOriginDataOnIndexedDBThread, indexed_db_context_, origin), 174 &DeleteOriginDataOnIndexedDBThread, indexed_db_context_, origin),
175 callback); 175 callback);
176 } 176 }
177 177
178 bool IndexedDBQuotaClient::DoesSupport(quota::StorageType type) const { 178 bool IndexedDBQuotaClient::DoesSupport(storage::StorageType type) const {
179 return type == quota::kStorageTypeTemporary; 179 return type == storage::kStorageTypeTemporary;
180 } 180 }
181 181
182 } // namespace content 182 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_quota_client.h ('k') | content/browser/indexed_db/indexed_db_quota_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698