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 #ifndef WEBKIT_QUOTA_USAGE_TRACKER_H_ | 5 #ifndef WEBKIT_QUOTA_USAGE_TRACKER_H_ |
6 #define WEBKIT_QUOTA_USAGE_TRACKER_H_ | 6 #define WEBKIT_QUOTA_USAGE_TRACKER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 24 matching lines...) Expand all Loading... |
35 virtual ~UsageTracker(); | 35 virtual ~UsageTracker(); |
36 | 36 |
37 StorageType type() const { return type_; } | 37 StorageType type() const { return type_; } |
38 ClientUsageTracker* GetClientTracker(QuotaClient::ID client_id); | 38 ClientUsageTracker* GetClientTracker(QuotaClient::ID client_id); |
39 | 39 |
40 void GetGlobalUsage(GlobalUsageCallback* callback); | 40 void GetGlobalUsage(GlobalUsageCallback* callback); |
41 void GetHostUsage(const std::string& host, HostUsageCallback* callback); | 41 void GetHostUsage(const std::string& host, HostUsageCallback* callback); |
42 void UpdateUsageCache(QuotaClient::ID client_id, | 42 void UpdateUsageCache(QuotaClient::ID client_id, |
43 const GURL& origin, | 43 const GURL& origin, |
44 int64 delta); | 44 int64 delta); |
45 | |
46 void GetCachedOrigins(std::set<GURL>* origins) const; | 45 void GetCachedOrigins(std::set<GURL>* origins) const; |
47 bool IsWorking(); | 46 bool IsWorking() const { |
| 47 return global_usage_callbacks_.HasCallbacks() || |
| 48 host_usage_callbacks_.HasAnyCallbacks(); |
| 49 } |
48 | 50 |
49 private: | 51 private: |
50 struct TrackingInfo { | 52 struct TrackingInfo { |
51 TrackingInfo() : pending_clients(0), usage(0), unlimited_usage(0) {} | 53 TrackingInfo() : pending_clients(0), usage(0), unlimited_usage(0) {} |
52 int pending_clients; | 54 int pending_clients; |
53 int64 usage; | 55 int64 usage; |
54 int64 unlimited_usage; | 56 int64 unlimited_usage; |
55 }; | 57 }; |
56 | 58 |
57 typedef std::map<QuotaClient::ID, ClientUsageTracker*> ClientTrackerMap; | 59 typedef std::map<QuotaClient::ID, ClientUsageTracker*> ClientTrackerMap; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 HostUsageCallbackMap host_usage_callbacks_; | 131 HostUsageCallbackMap host_usage_callbacks_; |
130 | 132 |
131 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; | 133 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; |
132 | 134 |
133 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); | 135 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); |
134 }; | 136 }; |
135 | 137 |
136 } // namespace quota | 138 } // namespace quota |
137 | 139 |
138 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_ | 140 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_ |
OLD | NEW |