Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: webkit/quota/usage_tracker.h

Issue 7606011: Track usage per-origin at the lowest level instead of per-host. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/quota/quota_manager.cc ('k') | webkit/quota/usage_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 class ClientUsageTracker { 80 class ClientUsageTracker {
81 public: 81 public:
82 ClientUsageTracker(UsageTracker* tracker, 82 ClientUsageTracker(UsageTracker* tracker,
83 QuotaClient* client, 83 QuotaClient* client,
84 StorageType type, 84 StorageType type,
85 SpecialStoragePolicy* special_storage_policy); 85 SpecialStoragePolicy* special_storage_policy);
86 ~ClientUsageTracker(); 86 ~ClientUsageTracker();
87 87
88 void GetGlobalUsage(GlobalUsageCallback* callback); 88 void GetGlobalUsage(GlobalUsageCallback* callback);
89 void GetHostUsage(const std::string& host, HostUsageCallback* callback); 89 void GetHostUsage(const std::string& host, HostUsageCallback* callback);
90 void DetermineOriginsToGetUsage(const std::set<GURL>& origins,
91 std::set<GURL>* origins_to_process);
92 void UpdateUsageCache(const GURL& origin, int64 delta); 90 void UpdateUsageCache(const GURL& origin, int64 delta);
93 91 void GetCachedOrigins(std::set<GURL>* origins) const;
94 const std::set<GURL>& cached_origins() const { return cached_origins_; }
95 92
96 private: 93 private:
94 typedef std::set<std::string> HostSet;
95 typedef std::map<GURL, int64> UsageMap;
96 typedef std::map<std::string, UsageMap> HostUsageMap;
97
97 class GatherUsageTaskBase; 98 class GatherUsageTaskBase;
98 class GatherGlobalUsageTask; 99 class GatherGlobalUsageTask;
99 class GatherHostUsageTask; 100 class GatherHostUsageTask;
100 101
101 void DidGetGlobalUsage(const std::map<GURL, int64>& origin_usage_map); 102 // Methods used by our GatherUsage tasks, as a task makes progress
102 void DidGetHostUsage(const std::string& host, 103 // origins and hosts are added incrementally to the cache.
103 const std::map<GURL, int64>& origin_usage_map); 104 void AddCachedOrigin(const GURL& origin, int64 usage);
105 void AddCachedHost(const std::string& host);
106 void GatherGlobalUsageComplete();
107 void GatherHostUsageComplete(const std::string& host);
108
109 int64 GetCachedHostUsage(const std::string& host);
110
111 void NoopHostUsageCallback(
112 const std::string& host, StorageType type, int64 usage);
113
104 bool IsStorageUnlimited(const GURL& origin) const; 114 bool IsStorageUnlimited(const GURL& origin) const;
105 115
106 UsageTracker* tracker_; 116 UsageTracker* tracker_;
107 QuotaClient* client_; 117 QuotaClient* client_;
108 const StorageType type_; 118 const StorageType type_;
109 std::set<GURL> cached_origins_;
110 119
111 int64 global_usage_; 120 int64 global_usage_;
112 int64 global_unlimited_usage_; 121 int64 global_unlimited_usage_;
113 bool global_usage_retrieved_; 122 bool global_usage_retrieved_;
123 HostSet cached_hosts_;
124 HostUsageMap cached_usage_;
125
114 GatherGlobalUsageTask* global_usage_task_; 126 GatherGlobalUsageTask* global_usage_task_;
115 GlobalUsageCallbackQueue global_usage_callback_; 127 GlobalUsageCallbackQueue global_usage_callback_;
116
117 std::map<std::string, int64> host_usage_map_;
118 std::map<std::string, GatherHostUsageTask*> host_usage_tasks_; 128 std::map<std::string, GatherHostUsageTask*> host_usage_tasks_;
119 HostUsageCallbackMap host_usage_callbacks_; 129 HostUsageCallbackMap host_usage_callbacks_;
120 130
121 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; 131 scoped_refptr<SpecialStoragePolicy> special_storage_policy_;
122 132
123 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker); 133 DISALLOW_COPY_AND_ASSIGN(ClientUsageTracker);
124 }; 134 };
125 135
126 } // namespace quota 136 } // namespace quota
127 137
128 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_ 138 #endif // WEBKIT_QUOTA_USAGE_TRACKER_H_
OLDNEW
« no previous file with comments | « webkit/quota/quota_manager.cc ('k') | webkit/quota/usage_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698