| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 STORAGE_BROWSER_QUOTA_CLIENT_USAGE_TRACKER_H_ | 5 #ifndef STORAGE_BROWSER_QUOTA_CLIENT_USAGE_TRACKER_H_ |
| 6 #define STORAGE_BROWSER_QUOTA_CLIENT_USAGE_TRACKER_H_ | 6 #define STORAGE_BROWSER_QUOTA_CLIENT_USAGE_TRACKER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/threading/non_thread_safe.h" | 18 #include "base/sequence_checker.h" |
| 19 #include "storage/browser/quota/quota_callbacks.h" | 19 #include "storage/browser/quota/quota_callbacks.h" |
| 20 #include "storage/browser/quota/quota_client.h" | 20 #include "storage/browser/quota/quota_client.h" |
| 21 #include "storage/browser/quota/quota_task.h" | 21 #include "storage/browser/quota/quota_task.h" |
| 22 #include "storage/browser/quota/special_storage_policy.h" | 22 #include "storage/browser/quota/special_storage_policy.h" |
| 23 #include "storage/browser/storage_browser_export.h" | 23 #include "storage/browser/storage_browser_export.h" |
| 24 #include "storage/common/quota/quota_types.h" | 24 #include "storage/common/quota/quota_types.h" |
| 25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 26 | 26 |
| 27 namespace storage { | 27 namespace storage { |
| 28 | 28 |
| 29 class StorageMonitor; | 29 class StorageMonitor; |
| 30 class UsageTracker; | 30 class UsageTracker; |
| 31 | 31 |
| 32 // This class holds per-client usage tracking information and caches per-host | 32 // This class holds per-client usage tracking information and caches per-host |
| 33 // usage data. An instance of this class is created per client. | 33 // usage data. An instance of this class is created per client. |
| 34 class ClientUsageTracker : public SpecialStoragePolicy::Observer, | 34 class ClientUsageTracker : public SpecialStoragePolicy::Observer, |
| 35 public base::NonThreadSafe, | |
| 36 public base::SupportsWeakPtr<ClientUsageTracker> { | 35 public base::SupportsWeakPtr<ClientUsageTracker> { |
| 37 public: | 36 public: |
| 38 typedef base::Callback<void(int64_t limited_usage, int64_t unlimited_usage)> | 37 typedef base::Callback<void(int64_t limited_usage, int64_t unlimited_usage)> |
| 39 HostUsageAccumulator; | 38 HostUsageAccumulator; |
| 40 typedef base::Callback<void(const GURL& origin, int64_t usage)> | 39 typedef base::Callback<void(const GURL& origin, int64_t usage)> |
| 41 OriginUsageAccumulator; | 40 OriginUsageAccumulator; |
| 42 typedef std::map<std::string, std::set<GURL> > OriginSetByHost; | 41 typedef std::map<std::string, std::set<GURL> > OriginSetByHost; |
| 43 | 42 |
| 44 ClientUsageTracker(UsageTracker* tracker, | 43 ClientUsageTracker(UsageTracker* tracker, |
| 45 QuotaClient* client, | 44 QuotaClient* client, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 HostSet cached_hosts_; | 124 HostSet cached_hosts_; |
| 126 HostUsageMap cached_usage_by_host_; | 125 HostUsageMap cached_usage_by_host_; |
| 127 | 126 |
| 128 OriginSetByHost non_cached_limited_origins_by_host_; | 127 OriginSetByHost non_cached_limited_origins_by_host_; |
| 129 OriginSetByHost non_cached_unlimited_origins_by_host_; | 128 OriginSetByHost non_cached_unlimited_origins_by_host_; |
| 130 | 129 |
| 131 HostUsageAccumulatorMap host_usage_accumulators_; | 130 HostUsageAccumulatorMap host_usage_accumulators_; |
| 132 | 131 |
| 133 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; | 132 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; |
| 134 | 133 |
| 134 SEQUENCE_CHECKER(sequence_checker_); |
| 135 |
| 135 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); | 136 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); |
| 136 }; | 137 }; |
| 137 | 138 |
| 138 } // namespace storage | 139 } // namespace storage |
| 139 | 140 |
| 140 #endif // STORAGE_BROWSER_QUOTA_CLIENT_USAGE_TRACKER_H_ | 141 #endif // STORAGE_BROWSER_QUOTA_CLIENT_USAGE_TRACKER_H_ |
| OLD | NEW |