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/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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/memory/ref_counted.h" | |
16 #include "base/message_loop_proxy.h" | 15 #include "base/message_loop_proxy.h" |
17 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
18 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
19 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
20 #include "base/time.h" | 19 #include "base/time.h" |
21 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
22 #include "webkit/quota/quota_database.h" | 21 #include "webkit/quota/quota_database.h" |
23 #include "webkit/quota/quota_temporary_storage_evictor.h" | 22 #include "webkit/quota/quota_temporary_storage_evictor.h" |
24 #include "webkit/quota/quota_types.h" | 23 #include "webkit/quota/quota_types.h" |
25 #include "webkit/quota/usage_tracker.h" | 24 #include "webkit/quota/usage_tracker.h" |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 io_thread_->DeleteSoon(FROM_HERE, this); | 1551 io_thread_->DeleteSoon(FROM_HERE, this); |
1553 return; | 1552 return; |
1554 } | 1553 } |
1555 delete this; | 1554 delete this; |
1556 } | 1555 } |
1557 | 1556 |
1558 // QuotaManagerProxy ---------------------------------------------------------- | 1557 // QuotaManagerProxy ---------------------------------------------------------- |
1559 | 1558 |
1560 void QuotaManagerProxy::RegisterClient(QuotaClient* client) { | 1559 void QuotaManagerProxy::RegisterClient(QuotaClient* client) { |
1561 if (!io_thread_->BelongsToCurrentThread()) { | 1560 if (!io_thread_->BelongsToCurrentThread()) { |
1562 io_thread_->PostTask(FROM_HERE, NewRunnableMethod( | 1561 io_thread_->PostTask( |
1563 this, &QuotaManagerProxy::RegisterClient, client)); | 1562 FROM_HERE, |
| 1563 base::Bind(&QuotaManagerProxy::RegisterClient, this, client)); |
1564 return; | 1564 return; |
1565 } | 1565 } |
| 1566 |
1566 if (manager_) | 1567 if (manager_) |
1567 manager_->RegisterClient(client); | 1568 manager_->RegisterClient(client); |
1568 else | 1569 else |
1569 client->OnQuotaManagerDestroyed(); | 1570 client->OnQuotaManagerDestroyed(); |
1570 } | 1571 } |
1571 | 1572 |
1572 void QuotaManagerProxy::NotifyStorageAccessed( | 1573 void QuotaManagerProxy::NotifyStorageAccessed( |
1573 QuotaClient::ID client_id, | 1574 QuotaClient::ID client_id, |
1574 const GURL& origin, | 1575 const GURL& origin, |
1575 StorageType type) { | 1576 StorageType type) { |
1576 if (!io_thread_->BelongsToCurrentThread()) { | 1577 if (!io_thread_->BelongsToCurrentThread()) { |
1577 io_thread_->PostTask(FROM_HERE, NewRunnableMethod( | 1578 io_thread_->PostTask( |
1578 this, &QuotaManagerProxy::NotifyStorageAccessed, | 1579 FROM_HERE, |
1579 client_id, origin, type)); | 1580 base::Bind(&QuotaManagerProxy::NotifyStorageAccessed, this, client_id, |
| 1581 origin, type)); |
1580 return; | 1582 return; |
1581 } | 1583 } |
| 1584 |
1582 if (manager_) | 1585 if (manager_) |
1583 manager_->NotifyStorageAccessed(client_id, origin, type); | 1586 manager_->NotifyStorageAccessed(client_id, origin, type); |
1584 } | 1587 } |
1585 | 1588 |
1586 void QuotaManagerProxy::NotifyStorageModified( | 1589 void QuotaManagerProxy::NotifyStorageModified( |
1587 QuotaClient::ID client_id, | 1590 QuotaClient::ID client_id, |
1588 const GURL& origin, | 1591 const GURL& origin, |
1589 StorageType type, | 1592 StorageType type, |
1590 int64 delta) { | 1593 int64 delta) { |
1591 if (!io_thread_->BelongsToCurrentThread()) { | 1594 if (!io_thread_->BelongsToCurrentThread()) { |
1592 io_thread_->PostTask(FROM_HERE, NewRunnableMethod( | 1595 io_thread_->PostTask( |
1593 this, &QuotaManagerProxy::NotifyStorageModified, | 1596 FROM_HERE, |
1594 client_id, origin, type, delta)); | 1597 base::Bind(&QuotaManagerProxy::NotifyStorageModified, this, client_id, |
| 1598 origin, type, delta)); |
1595 return; | 1599 return; |
1596 } | 1600 } |
| 1601 |
1597 if (manager_) | 1602 if (manager_) |
1598 manager_->NotifyStorageModified(client_id, origin, type, delta); | 1603 manager_->NotifyStorageModified(client_id, origin, type, delta); |
1599 } | 1604 } |
1600 | 1605 |
1601 void QuotaManagerProxy::NotifyOriginInUse( | 1606 void QuotaManagerProxy::NotifyOriginInUse( |
1602 const GURL& origin) { | 1607 const GURL& origin) { |
1603 if (!io_thread_->BelongsToCurrentThread()) { | 1608 if (!io_thread_->BelongsToCurrentThread()) { |
1604 io_thread_->PostTask(FROM_HERE, NewRunnableMethod( | 1609 io_thread_->PostTask( |
1605 this, &QuotaManagerProxy::NotifyOriginInUse, origin)); | 1610 FROM_HERE, |
| 1611 base::Bind(&QuotaManagerProxy::NotifyOriginInUse, this, origin)); |
1606 return; | 1612 return; |
1607 } | 1613 } |
| 1614 |
1608 if (manager_) | 1615 if (manager_) |
1609 manager_->NotifyOriginInUse(origin); | 1616 manager_->NotifyOriginInUse(origin); |
1610 } | 1617 } |
1611 | 1618 |
1612 void QuotaManagerProxy::NotifyOriginNoLongerInUse( | 1619 void QuotaManagerProxy::NotifyOriginNoLongerInUse( |
1613 const GURL& origin) { | 1620 const GURL& origin) { |
1614 if (!io_thread_->BelongsToCurrentThread()) { | 1621 if (!io_thread_->BelongsToCurrentThread()) { |
1615 io_thread_->PostTask(FROM_HERE, NewRunnableMethod( | 1622 io_thread_->PostTask( |
1616 this, &QuotaManagerProxy::NotifyOriginNoLongerInUse, origin)); | 1623 FROM_HERE, |
| 1624 base::Bind(&QuotaManagerProxy::NotifyOriginNoLongerInUse, this, |
| 1625 origin)); |
1617 return; | 1626 return; |
1618 } | 1627 } |
1619 if (manager_) | 1628 if (manager_) |
1620 manager_->NotifyOriginNoLongerInUse(origin); | 1629 manager_->NotifyOriginNoLongerInUse(origin); |
1621 } | 1630 } |
1622 | 1631 |
1623 QuotaManager* QuotaManagerProxy::quota_manager() const { | 1632 QuotaManager* QuotaManagerProxy::quota_manager() const { |
1624 DCHECK(!io_thread_ || io_thread_->BelongsToCurrentThread()); | 1633 DCHECK(!io_thread_ || io_thread_->BelongsToCurrentThread()); |
1625 return manager_; | 1634 return manager_; |
1626 } | 1635 } |
1627 | 1636 |
1628 QuotaManagerProxy::QuotaManagerProxy( | 1637 QuotaManagerProxy::QuotaManagerProxy( |
1629 QuotaManager* manager, base::MessageLoopProxy* io_thread) | 1638 QuotaManager* manager, base::MessageLoopProxy* io_thread) |
1630 : manager_(manager), io_thread_(io_thread) { | 1639 : manager_(manager), io_thread_(io_thread) { |
1631 } | 1640 } |
1632 | 1641 |
1633 QuotaManagerProxy::~QuotaManagerProxy() { | 1642 QuotaManagerProxy::~QuotaManagerProxy() { |
1634 } | 1643 } |
1635 | 1644 |
1636 } // namespace quota | 1645 } // namespace quota |
OLD | NEW |