| 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/appcache/appcache_storage_impl.h" | 5 #include "webkit/appcache/appcache_storage_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 if (!quota_manager) { | 542 if (!quota_manager) { |
| 543 if (storage_->service()->special_storage_policy() && | 543 if (storage_->service()->special_storage_policy() && |
| 544 storage_->service()->special_storage_policy()->IsStorageUnlimited( | 544 storage_->service()->special_storage_policy()->IsStorageUnlimited( |
| 545 group_record_.origin)) | 545 group_record_.origin)) |
| 546 space_available_ = kint64max; | 546 space_available_ = kint64max; |
| 547 Schedule(); | 547 Schedule(); |
| 548 return; | 548 return; |
| 549 } | 549 } |
| 550 | 550 |
| 551 // We have to ask the quota manager for the value. | 551 // We have to ask the quota manager for the value. |
| 552 AddRef(); // balanced in the OnQuotaCallback | |
| 553 storage_->pending_quota_queries_.insert(this); | 552 storage_->pending_quota_queries_.insert(this); |
| 554 quota_manager->GetUsageAndQuota( | 553 quota_manager->GetUsageAndQuota( |
| 555 group_record_.origin, quota::kStorageTypeTemporary, | 554 group_record_.origin, quota::kStorageTypeTemporary, |
| 556 base::Bind(&StoreGroupAndCacheTask::OnQuotaCallback, | 555 base::Bind(&StoreGroupAndCacheTask::OnQuotaCallback, this)); |
| 557 base::Unretained(this))); | |
| 558 } | 556 } |
| 559 | 557 |
| 560 void AppCacheStorageImpl::StoreGroupAndCacheTask::OnQuotaCallback( | 558 void AppCacheStorageImpl::StoreGroupAndCacheTask::OnQuotaCallback( |
| 561 quota::QuotaStatusCode status, int64 usage, int64 quota) { | 559 quota::QuotaStatusCode status, int64 usage, int64 quota) { |
| 562 if (storage_) { | 560 if (storage_) { |
| 563 if (status == quota::kQuotaStatusOk) | 561 if (status == quota::kQuotaStatusOk) |
| 564 space_available_ = std::max(static_cast<int64>(0), quota - usage); | 562 space_available_ = std::max(static_cast<int64>(0), quota - usage); |
| 565 else | 563 else |
| 566 space_available_ = 0; | 564 space_available_ = 0; |
| 567 storage_->pending_quota_queries_.erase(this); | 565 storage_->pending_quota_queries_.erase(this); |
| 568 Schedule(); | 566 Schedule(); |
| 569 } | 567 } |
| 570 Release(); // balanced in GetQuotaThenSchedule | |
| 571 } | 568 } |
| 572 | 569 |
| 573 void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { | 570 void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { |
| 574 DCHECK(!success_); | 571 DCHECK(!success_); |
| 575 sql::Connection* connection = database_->db_connection(); | 572 sql::Connection* connection = database_->db_connection(); |
| 576 if (!connection) | 573 if (!connection) |
| 577 return; | 574 return; |
| 578 | 575 |
| 579 sql::Transaction transaction(connection); | 576 sql::Transaction transaction(connection); |
| 580 if (!transaction.Begin()) | 577 if (!transaction.Begin()) |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 Disable(); | 1649 Disable(); |
| 1653 if (!is_incognito_) { | 1650 if (!is_incognito_) { |
| 1654 VLOG(1) << "Deleting existing appcache data and starting over."; | 1651 VLOG(1) << "Deleting existing appcache data and starting over."; |
| 1655 db_thread_->PostTask(FROM_HERE, | 1652 db_thread_->PostTask(FROM_HERE, |
| 1656 NewRunnableFunction(DeleteDirectory, cache_directory_)); | 1653 NewRunnableFunction(DeleteDirectory, cache_directory_)); |
| 1657 } | 1654 } |
| 1658 } | 1655 } |
| 1659 } | 1656 } |
| 1660 | 1657 |
| 1661 } // namespace appcache | 1658 } // namespace appcache |
| OLD | NEW |