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

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

Issue 7533013: Quota: Add quota::StorageType to the GetOriginsCallback definition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing onto today's ToT. Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/in_process_webkit/indexed_db_quota_client.h" 5 #include "content/browser/in_process_webkit/indexed_db_quota_client.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 } 78 }
79 79
80 std::set<GURL> origins_; 80 std::set<GURL> origins_;
81 }; 81 };
82 82
83 class IndexedDBQuotaClient::GetAllOriginsTask : public GetOriginsTaskBase { 83 class IndexedDBQuotaClient::GetAllOriginsTask : public GetOriginsTaskBase {
84 public: 84 public:
85 GetAllOriginsTask( 85 GetAllOriginsTask(
86 IndexedDBQuotaClient* client, 86 IndexedDBQuotaClient* client,
87 base::MessageLoopProxy* webkit_thread_message_loop) 87 base::MessageLoopProxy* webkit_thread_message_loop,
88 : GetOriginsTaskBase(client, webkit_thread_message_loop) { 88 quota::StorageType type)
89 : GetOriginsTaskBase(client, webkit_thread_message_loop),
90 type_(type) {
89 } 91 }
90 92
91 protected: 93 protected:
92 virtual bool ShouldAddOrigin(const GURL& origin) OVERRIDE { 94 virtual bool ShouldAddOrigin(const GURL& origin) OVERRIDE {
93 return true; 95 return true;
94 } 96 }
95 virtual void Completed() OVERRIDE { 97 virtual void Completed() OVERRIDE {
96 client_->DidGetAllOrigins(origins_); 98 client_->DidGetAllOrigins(origins_, type_);
97 } 99 }
100
101 private:
102 quota::StorageType type_;
98 }; 103 };
99 104
100 class IndexedDBQuotaClient::GetOriginsForHostTask : public GetOriginsTaskBase { 105 class IndexedDBQuotaClient::GetOriginsForHostTask : public GetOriginsTaskBase {
101 public: 106 public:
102 GetOriginsForHostTask( 107 GetOriginsForHostTask(
103 IndexedDBQuotaClient* client, 108 IndexedDBQuotaClient* client,
104 base::MessageLoopProxy* webkit_thread_message_loop, 109 base::MessageLoopProxy* webkit_thread_message_loop,
105 const std::string& host) 110 const std::string& host,
111 quota::StorageType type)
106 : GetOriginsTaskBase(client, webkit_thread_message_loop), 112 : GetOriginsTaskBase(client, webkit_thread_message_loop),
107 host_(host) { 113 host_(host),
114 type_(type) {
108 } 115 }
109 116
110 private: 117 private:
111 virtual bool ShouldAddOrigin(const GURL& origin) OVERRIDE { 118 virtual bool ShouldAddOrigin(const GURL& origin) OVERRIDE {
112 return host_ == net::GetHostOrSpecFromURL(origin); 119 return host_ == net::GetHostOrSpecFromURL(origin);
113 } 120 }
114 virtual void Completed() OVERRIDE { 121 virtual void Completed() OVERRIDE {
115 client_->DidGetOriginsForHost(host_, origins_); 122 client_->DidGetOriginsForHost(host_, origins_, type_);
116 } 123 }
117 std::string host_; 124 std::string host_;
125 quota::StorageType type_;
118 }; 126 };
119 127
120 // IndexedDBQuotaClient -------------------------------------------------------- 128 // IndexedDBQuotaClient --------------------------------------------------------
121 129
122 IndexedDBQuotaClient::IndexedDBQuotaClient( 130 IndexedDBQuotaClient::IndexedDBQuotaClient(
123 base::MessageLoopProxy* webkit_thread_message_loop, 131 base::MessageLoopProxy* webkit_thread_message_loop,
124 IndexedDBContext* indexed_db_context) 132 IndexedDBContext* indexed_db_context)
125 : webkit_thread_message_loop_(webkit_thread_message_loop), 133 : webkit_thread_message_loop_(webkit_thread_message_loop),
126 indexed_db_context_(indexed_db_context) { 134 indexed_db_context_(indexed_db_context) {
127 } 135 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 168
161 void IndexedDBQuotaClient::GetOriginsForType( 169 void IndexedDBQuotaClient::GetOriginsForType(
162 quota::StorageType type, 170 quota::StorageType type,
163 GetOriginsCallback* callback_ptr) { 171 GetOriginsCallback* callback_ptr) {
164 DCHECK(callback_ptr); 172 DCHECK(callback_ptr);
165 DCHECK(indexed_db_context_.get()); 173 DCHECK(indexed_db_context_.get());
166 scoped_ptr<GetOriginsCallback> callback(callback_ptr); 174 scoped_ptr<GetOriginsCallback> callback(callback_ptr);
167 175
168 // All databases are in the temp namespace for now. 176 // All databases are in the temp namespace for now.
169 if (type != quota::kStorageTypeTemporary) { 177 if (type != quota::kStorageTypeTemporary) {
170 callback->Run(std::set<GURL>()); 178 callback->Run(std::set<GURL>(), type);
171 return; 179 return;
172 } 180 }
173 181
174 if (origins_for_type_callbacks_.Add(callback.release())) { 182 if (origins_for_type_callbacks_.Add(callback.release())) {
175 scoped_refptr<GetAllOriginsTask> task( 183 scoped_refptr<GetAllOriginsTask> task(
176 new GetAllOriginsTask(this, webkit_thread_message_loop_)); 184 new GetAllOriginsTask(this, webkit_thread_message_loop_, type));
177 task->Start(); 185 task->Start();
178 } 186 }
179 } 187 }
180 188
181 void IndexedDBQuotaClient::GetOriginsForHost( 189 void IndexedDBQuotaClient::GetOriginsForHost(
182 quota::StorageType type, 190 quota::StorageType type,
183 const std::string& host, 191 const std::string& host,
184 GetOriginsCallback* callback_ptr) { 192 GetOriginsCallback* callback_ptr) {
185 DCHECK(callback_ptr); 193 DCHECK(callback_ptr);
186 DCHECK(indexed_db_context_.get()); 194 DCHECK(indexed_db_context_.get());
187 scoped_ptr<GetOriginsCallback> callback(callback_ptr); 195 scoped_ptr<GetOriginsCallback> callback(callback_ptr);
188 196
189 // All databases are in the temp namespace for now. 197 // All databases are in the temp namespace for now.
190 if (type != quota::kStorageTypeTemporary) { 198 if (type != quota::kStorageTypeTemporary) {
191 callback->Run(std::set<GURL>()); 199 callback->Run(std::set<GURL>(), type);
192 return; 200 return;
193 } 201 }
194 202
195 if (origins_for_host_callbacks_.Add(host, callback.release())) { 203 if (origins_for_host_callbacks_.Add(host, callback.release())) {
196 scoped_refptr<GetOriginsForHostTask> task( 204 scoped_refptr<GetOriginsForHostTask> task(
197 new GetOriginsForHostTask(this, webkit_thread_message_loop_, host)); 205 new GetOriginsForHostTask(
206 this, webkit_thread_message_loop_, host, type));
198 task->Start(); 207 task->Start();
199 } 208 }
200 } 209 }
201 210
202 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin, 211 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin,
203 quota::StorageType type, 212 quota::StorageType type,
204 DeletionCallback* callback) { 213 DeletionCallback* callback) {
205 // TODO(tzik): implement me 214 // TODO(tzik): implement me
206 callback->Run(quota::kQuotaErrorNotSupported); 215 callback->Run(quota::kQuotaErrorNotSupported);
207 delete callback; 216 delete callback;
208 } 217 }
209 218
210 void IndexedDBQuotaClient::DidGetOriginUsage( 219 void IndexedDBQuotaClient::DidGetOriginUsage(
211 const GURL& origin_url, int64 usage) { 220 const GURL& origin_url, int64 usage) {
212 DCHECK(usage_for_origin_callbacks_.HasCallbacks(origin_url)); 221 DCHECK(usage_for_origin_callbacks_.HasCallbacks(origin_url));
213 usage_for_origin_callbacks_.Run(origin_url, usage); 222 usage_for_origin_callbacks_.Run(origin_url, usage);
214 } 223 }
215 224
216 void IndexedDBQuotaClient::DidGetAllOrigins(const std::set<GURL>& origins) { 225 void IndexedDBQuotaClient::DidGetAllOrigins(const std::set<GURL>& origins,
226 quota::StorageType type) {
217 DCHECK(origins_for_type_callbacks_.HasCallbacks()); 227 DCHECK(origins_for_type_callbacks_.HasCallbacks());
218 origins_for_type_callbacks_.Run(origins); 228 origins_for_type_callbacks_.Run(origins, type);
219 } 229 }
220 230
221 void IndexedDBQuotaClient::DidGetOriginsForHost( 231 void IndexedDBQuotaClient::DidGetOriginsForHost(
222 const std::string& host, const std::set<GURL>& origins) { 232 const std::string& host, const std::set<GURL>& origins,
233 quota::StorageType type) {
223 DCHECK(origins_for_host_callbacks_.HasCallbacks(host)); 234 DCHECK(origins_for_host_callbacks_.HasCallbacks(host));
224 origins_for_host_callbacks_.Run(host, origins); 235 origins_for_host_callbacks_.Run(host, origins, type);
225 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698