| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quota/quota_manager.h" | 5 #include "webkit/quota/quota_manager.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <deque> | 8 #include <deque> | 
| 9 #include <set> | 9 #include <set> | 
| 10 | 10 | 
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1130     io_thread_(io_thread), | 1130     io_thread_(io_thread), | 
| 1131     db_thread_(db_thread), | 1131     db_thread_(db_thread), | 
| 1132     temporary_quota_initialized_(false), | 1132     temporary_quota_initialized_(false), | 
| 1133     temporary_quota_override_(-1), | 1133     temporary_quota_override_(-1), | 
| 1134     desired_available_space_(-1), | 1134     desired_available_space_(-1), | 
| 1135     special_storage_policy_(special_storage_policy), | 1135     special_storage_policy_(special_storage_policy), | 
| 1136     weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 1136     weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 
| 1137 } | 1137 } | 
| 1138 | 1138 | 
| 1139 QuotaManager::~QuotaManager() { | 1139 QuotaManager::~QuotaManager() { | 
| 1140   DCHECK(io_thread_->BelongsToCurrentThread()); |  | 
| 1141   proxy_->manager_ = NULL; | 1140   proxy_->manager_ = NULL; | 
| 1142   std::for_each(clients_.begin(), clients_.end(), | 1141   std::for_each(clients_.begin(), clients_.end(), | 
| 1143                 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); | 1142                 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); | 
| 1144   if (database_.get()) | 1143   if (database_.get()) | 
| 1145     db_thread_->DeleteSoon(FROM_HERE, database_.release()); | 1144     db_thread_->DeleteSoon(FROM_HERE, database_.release()); | 
| 1146 } | 1145 } | 
| 1147 | 1146 | 
| 1148 void QuotaManager::GetUsageInfo(const GetUsageInfoCallback& callback) { | 1147 void QuotaManager::GetUsageInfo(const GetUsageInfoCallback& callback) { | 
| 1149   LazyInitialize(); | 1148   LazyInitialize(); | 
| 1150   GetUsageInfoTask* get_usage_info = new GetUsageInfoTask(this, callback); | 1149   GetUsageInfoTask* get_usage_info = new GetUsageInfoTask(this, callback); | 
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1290       new UsageTracker(clients_, kStorageTypeTemporary, | 1289       new UsageTracker(clients_, kStorageTypeTemporary, | 
| 1291                        special_storage_policy_)); | 1290                        special_storage_policy_)); | 
| 1292   persistent_usage_tracker_.reset( | 1291   persistent_usage_tracker_.reset( | 
| 1293       new UsageTracker(clients_, kStorageTypePersistent, | 1292       new UsageTracker(clients_, kStorageTypePersistent, | 
| 1294                        special_storage_policy_)); | 1293                        special_storage_policy_)); | 
| 1295 | 1294 | 
| 1296   make_scoped_refptr(new InitializeTask(this))->Start(); | 1295   make_scoped_refptr(new InitializeTask(this))->Start(); | 
| 1297 } | 1296 } | 
| 1298 | 1297 | 
| 1299 void QuotaManager::RegisterClient(QuotaClient* client) { | 1298 void QuotaManager::RegisterClient(QuotaClient* client) { | 
| 1300   DCHECK(io_thread_->BelongsToCurrentThread()); |  | 
| 1301   DCHECK(!database_.get()); | 1299   DCHECK(!database_.get()); | 
| 1302   clients_.push_back(client); | 1300   clients_.push_back(client); | 
| 1303 } | 1301 } | 
| 1304 | 1302 | 
| 1305 void QuotaManager::NotifyStorageAccessed( | 1303 void QuotaManager::NotifyStorageAccessed( | 
| 1306     QuotaClient::ID client_id, | 1304     QuotaClient::ID client_id, | 
| 1307     const GURL& origin, StorageType type) { | 1305     const GURL& origin, StorageType type) { | 
| 1308   NotifyStorageAccessedInternal(client_id, origin, type, base::Time::Now()); | 1306   NotifyStorageAccessedInternal(client_id, origin, type, base::Time::Now()); | 
| 1309 } | 1307 } | 
| 1310 | 1308 | 
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1667   if (origins_in_use_.find(origin) != origins_in_use_.end() || | 1665   if (origins_in_use_.find(origin) != origins_in_use_.end() || | 
| 1668       access_notified_origins_.find(origin) != access_notified_origins_.end()) | 1666       access_notified_origins_.find(origin) != access_notified_origins_.end()) | 
| 1669     lru_origin_callback_.Run(GURL()); | 1667     lru_origin_callback_.Run(GURL()); | 
| 1670   else | 1668   else | 
| 1671     lru_origin_callback_.Run(origin); | 1669     lru_origin_callback_.Run(origin); | 
| 1672   access_notified_origins_.clear(); | 1670   access_notified_origins_.clear(); | 
| 1673   lru_origin_callback_.Reset(); | 1671   lru_origin_callback_.Reset(); | 
| 1674 } | 1672 } | 
| 1675 | 1673 | 
| 1676 void QuotaManager::DeleteOnCorrectThread() const { | 1674 void QuotaManager::DeleteOnCorrectThread() const { | 
| 1677   if (!io_thread_->BelongsToCurrentThread()) { | 1675   if (!io_thread_->BelongsToCurrentThread() && | 
| 1678     io_thread_->DeleteSoon(FROM_HERE, this); | 1676       io_thread_->DeleteSoon(FROM_HERE, this)) { | 
| 1679     return; | 1677     return; | 
| 1680   } | 1678   } | 
| 1681   delete this; | 1679   delete this; | 
| 1682 } | 1680 } | 
| 1683 | 1681 | 
| 1684 // QuotaManagerProxy ---------------------------------------------------------- | 1682 // QuotaManagerProxy ---------------------------------------------------------- | 
| 1685 | 1683 | 
| 1686 void QuotaManagerProxy::RegisterClient(QuotaClient* client) { | 1684 void QuotaManagerProxy::RegisterClient(QuotaClient* client) { | 
| 1687   if (!io_thread_->BelongsToCurrentThread()) { | 1685   if (!io_thread_->BelongsToCurrentThread() && | 
| 1688     io_thread_->PostTask( | 1686       io_thread_->PostTask( | 
| 1689         FROM_HERE, | 1687           FROM_HERE, | 
| 1690         base::Bind(&QuotaManagerProxy::RegisterClient, this, client)); | 1688           base::Bind(&QuotaManagerProxy::RegisterClient, this, client))) { | 
| 1691     return; | 1689     return; | 
| 1692   } | 1690   } | 
| 1693 | 1691 | 
| 1694   if (manager_) | 1692   if (manager_) | 
| 1695     manager_->RegisterClient(client); | 1693     manager_->RegisterClient(client); | 
| 1696   else | 1694   else | 
| 1697     client->OnQuotaManagerDestroyed(); | 1695     client->OnQuotaManagerDestroyed(); | 
| 1698 } | 1696 } | 
| 1699 | 1697 | 
| 1700 void QuotaManagerProxy::NotifyStorageAccessed( | 1698 void QuotaManagerProxy::NotifyStorageAccessed( | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1763 | 1761 | 
| 1764 QuotaManagerProxy::QuotaManagerProxy( | 1762 QuotaManagerProxy::QuotaManagerProxy( | 
| 1765     QuotaManager* manager, base::MessageLoopProxy* io_thread) | 1763     QuotaManager* manager, base::MessageLoopProxy* io_thread) | 
| 1766     : manager_(manager), io_thread_(io_thread) { | 1764     : manager_(manager), io_thread_(io_thread) { | 
| 1767 } | 1765 } | 
| 1768 | 1766 | 
| 1769 QuotaManagerProxy::~QuotaManagerProxy() { | 1767 QuotaManagerProxy::~QuotaManagerProxy() { | 
| 1770 } | 1768 } | 
| 1771 | 1769 | 
| 1772 }  // namespace quota | 1770 }  // namespace quota | 
| OLD | NEW | 
|---|