Chromium Code Reviews| 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), type_(type), | |
|
kinuko
2011/05/11 12:18:49
nit: type_() in the next line
tzik (google)
2011/05/12 10:47:06
Done.
| |
| 304 status_(quota::kQuotaStatusUnknown), | |
| 305 callback_(callback) { | |
| 306 } | |
| 307 | |
| 308 virtual ~DeleteOriginTask() {} | |
| 309 | |
| 310 virtual void RunOnTargetThread() OVERRIDE { | |
| 311 if (file_system_context_ | |
| 312 ->DeleteDataForOriginAndTypeOnFileThread(origin_, type_)) | |
|
kinuko
2011/05/11 12:18:49
style nit: weird indentation
not sure what would
tzik (google)
2011/05/12 10:47:06
Done.
| |
| 313 status_ = quota::kQuotaStatusOk; | |
| 314 else | |
| 315 status_ = quota::kQuotaErrorInvalidModification; | |
| 316 } | |
| 317 | |
| 318 virtual void Aborted() OVERRIDE { | |
| 319 status_ = quota::kQuotaErrorAbort; | |
| 320 callback_->Run(status_); | |
| 321 delete callback_; | |
| 322 } | |
| 323 | |
| 324 virtual void Completed() OVERRIDE { | |
| 325 callback_->Run(status_); | |
| 326 delete callback_; | |
| 327 } | |
| 328 private: | |
| 329 FileSystemContext* file_system_context_; | |
| 330 GURL origin_; | |
| 331 FileSystemType type_; | |
| 332 quota::QuotaStatusCode status_; | |
| 333 DeletionCallback* callback_; | |
| 334 }; | |
| 335 | |
| 336 void SandboxQuotaClient::DeleteOriginData(const GURL& origin, | |
| 337 StorageType type, | |
| 338 DeletionCallback* callback) { | |
| 339 FileSystemType fs_type = QuotaStorageTypeToFileSystemType(type); | |
| 340 DCHECK(fs_type != kFileSystemTypeUnknown); | |
| 341 scoped_ptr<DeleteOriginTask> task( | |
| 342 new DeleteOriginTask(this, file_message_loop_, | |
|
kinuko
2011/05/12 05:54:15
Sorry, please forget what I said about ScopedRunna
| |
| 343 origin, fs_type, callback)); | |
| 344 task->Start(); | |
| 345 } | |
| 346 | |
| 292 } // namespace fileapi | 347 } // namespace fileapi |
| OLD | NEW |