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/appcache/appcache_storage_impl.h" | 5 #include "webkit/appcache/appcache_storage_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | |
| 8 #include <functional> | |
| 7 #include <set> | 9 #include <set> |
| 10 #include <vector> | |
| 8 | 11 |
| 12 #include "base/bind.h" | |
| 9 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 14 #include "base/logging.h" |
| 11 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 12 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 13 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 14 #include "net/base/cache_type.h" | 18 #include "net/base/cache_type.h" |
| 15 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 16 #include "sql/connection.h" | 20 #include "sql/connection.h" |
| 17 #include "sql/transaction.h" | 21 #include "sql/transaction.h" |
| 18 #include "webkit/appcache/appcache.h" | 22 #include "webkit/appcache/appcache.h" |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 if (!quota_manager) { | 542 if (!quota_manager) { |
| 539 if (storage_->service()->special_storage_policy() && | 543 if (storage_->service()->special_storage_policy() && |
| 540 storage_->service()->special_storage_policy()->IsStorageUnlimited( | 544 storage_->service()->special_storage_policy()->IsStorageUnlimited( |
| 541 group_record_.origin)) | 545 group_record_.origin)) |
| 542 space_available_ = kint64max; | 546 space_available_ = kint64max; |
| 543 Schedule(); | 547 Schedule(); |
| 544 return; | 548 return; |
| 545 } | 549 } |
| 546 | 550 |
| 547 // We have to ask the quota manager for the value. | 551 // We have to ask the quota manager for the value. |
| 548 AddRef(); // balanced in the OnQuotaCallback | 552 AddRef(); // balanced in the OnQuotaCallback |
|
michaeln
2011/10/03 18:51:27
Is the manual AddRef() and balancing Release() nee
tzik
2011/10/11 04:53:57
TODO in another CL.
| |
| 549 storage_->pending_quota_queries_.insert(this); | 553 storage_->pending_quota_queries_.insert(this); |
| 550 quota_manager->GetUsageAndQuota( | 554 quota_manager->GetUsageAndQuota( |
| 551 group_record_.origin, quota::kStorageTypeTemporary, | 555 group_record_.origin, quota::kStorageTypeTemporary, |
| 552 NewCallback(this, &StoreGroupAndCacheTask::OnQuotaCallback)); | 556 base::Bind(&StoreGroupAndCacheTask::OnQuotaCallback, |
| 557 base::Unretained(this))); | |
| 553 } | 558 } |
| 554 | 559 |
| 555 void AppCacheStorageImpl::StoreGroupAndCacheTask::OnQuotaCallback( | 560 void AppCacheStorageImpl::StoreGroupAndCacheTask::OnQuotaCallback( |
| 556 quota::QuotaStatusCode status, int64 usage, int64 quota) { | 561 quota::QuotaStatusCode status, int64 usage, int64 quota) { |
| 557 if (storage_) { | 562 if (storage_) { |
| 558 if (status == quota::kQuotaStatusOk) | 563 if (status == quota::kQuotaStatusOk) |
| 559 space_available_ = std::max(static_cast<int64>(0), quota - usage); | 564 space_available_ = std::max(static_cast<int64>(0), quota - usage); |
| 560 else | 565 else |
| 561 space_available_ = 0; | 566 space_available_ = 0; |
| 562 storage_->pending_quota_queries_.erase(this); | 567 storage_->pending_quota_queries_.erase(this); |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1647 Disable(); | 1652 Disable(); |
| 1648 if (!is_incognito_) { | 1653 if (!is_incognito_) { |
| 1649 VLOG(1) << "Deleting existing appcache data and starting over."; | 1654 VLOG(1) << "Deleting existing appcache data and starting over."; |
| 1650 db_thread_->PostTask(FROM_HERE, | 1655 db_thread_->PostTask(FROM_HERE, |
| 1651 NewRunnableFunction(DeleteDirectory, cache_directory_)); | 1656 NewRunnableFunction(DeleteDirectory, cache_directory_)); |
| 1652 } | 1657 } |
| 1653 } | 1658 } |
| 1654 } | 1659 } |
| 1655 | 1660 |
| 1656 } // namespace appcache | 1661 } // namespace appcache |
| OLD | NEW |