OLD | NEW |
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 Loading... |
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 Completed() OVERRIDE { |
| 320 callback_->Run(status_); |
| 321 } |
| 322 private: |
| 323 FileSystemContext* file_system_context_; |
| 324 GURL origin_; |
| 325 FileSystemType type_; |
| 326 quota::QuotaStatusCode status_; |
| 327 scoped_ptr<DeletionCallback> callback_; |
| 328 }; |
| 329 |
| 330 void SandboxQuotaClient::DeleteOriginData(const GURL& origin, |
| 331 StorageType type, |
| 332 DeletionCallback* callback) { |
| 333 FileSystemType fs_type = QuotaStorageTypeToFileSystemType(type); |
| 334 DCHECK(fs_type != kFileSystemTypeUnknown); |
| 335 scoped_ptr<DeleteOriginTask> task( |
| 336 new DeleteOriginTask(this, file_message_loop_, |
| 337 origin, fs_type, callback)); |
| 338 task->Start(); |
| 339 } |
| 340 |
292 } // namespace fileapi | 341 } // namespace fileapi |
OLD | NEW |