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

Side by Side Diff: webkit/fileapi/sandbox_quota_client.cc

Issue 7003021: Added DeleteOriginData to QuotaClient (Closed)
Patch Set: Apply patch from issue 7013018 Created 9 years, 7 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
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 "webkit/fileapi/sandbox_quota_client.h" 5 #include "webkit/fileapi/sandbox_quota_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 DCHECK(pending_origins_for_type_callbacks_.HasCallbacks(type)); 282 DCHECK(pending_origins_for_type_callbacks_.HasCallbacks(type));
283 pending_origins_for_type_callbacks_.Run(type, origins); 283 pending_origins_for_type_callbacks_.Run(type, origins);
284 } 284 }
285 285
286 void SandboxQuotaClient::DidGetOriginsForHost( 286 void SandboxQuotaClient::DidGetOriginsForHost(
287 const TypeAndHostOrOrigin& type_and_host, const std::set<GURL>& origins) { 287 const TypeAndHostOrOrigin& type_and_host, const std::set<GURL>& origins) {
288 DCHECK(pending_origins_for_host_callbacks_.HasCallbacks(type_and_host)); 288 DCHECK(pending_origins_for_host_callbacks_.HasCallbacks(type_and_host));
289 pending_origins_for_host_callbacks_.Run(type_and_host, origins); 289 pending_origins_for_host_callbacks_.Run(type_and_host, origins);
290 } 290 }
291 291
292 class SandboxQuotaClient::DeleteOriginTask
293 : public QuotaThreadTask {
294 public:
295 DeleteOriginTask(
296 SandboxQuotaClient* quota_client,
297 scoped_refptr<MessageLoopProxy> file_message_loop,
298 const GURL& origin,
299 FileSystemType type,
300 DeletionCallback* callback)
301 : QuotaThreadTask(quota_client, file_message_loop),
302 file_system_context_(quota_client->file_system_context_),
303 origin_(origin),
304 type_(type),
305 status_(quota::kQuotaStatusUnknown),
306 callback_(callback) {
307 }
308
309 virtual ~DeleteOriginTask() {}
310
311 virtual void RunOnTargetThread() OVERRIDE {
312 if (file_system_context_->
313 DeleteDataForOriginAndTypeOnFileThread(origin_, type_))
314 status_ = quota::kQuotaStatusOk;
315 else
316 status_ = quota::kQuotaErrorInvalidModification;
317 }
318
319 virtual void Aborted() OVERRIDE {
320 status_ = quota::kQuotaErrorAbort;
321 callback_->Run(status_);
kinuko 2011/05/12 08:59:22 hmm do we need to fire the callback in abort case?
tzik (google) 2011/05/12 10:47:06 Done.
322 delete callback_;
323 }
324
325 virtual void Completed() OVERRIDE {
326 callback_->Run(status_);
327 delete callback_;
328 }
329 private:
330 FileSystemContext* file_system_context_;
331 GURL origin_;
332 FileSystemType type_;
333 quota::QuotaStatusCode status_;
334 DeletionCallback* callback_;
335 };
336
337 void SandboxQuotaClient::DeleteOriginData(const GURL& origin,
338 StorageType type,
339 DeletionCallback* callback) {
340 FileSystemType fs_type = QuotaStorageTypeToFileSystemType(type);
341 DCHECK(fs_type != kFileSystemTypeUnknown);
342 scoped_ptr<DeleteOriginTask> task(
343 new DeleteOriginTask(this, file_message_loop_,
344 origin, fs_type, callback));
345 task->Start();
346 }
347
292 } // namespace fileapi 348 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698