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

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

Issue 11274003: webkit: Merge 'database' and 'quota' to 'webkit_storage' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More EXPORT for Win Created 8 years, 1 month 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_database.h ('k') | webkit/quota/quota_task.h » ('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) 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 #ifndef WEBKIT_QUOTA_QUOTA_MANAGER_H_ 5 #ifndef WEBKIT_QUOTA_QUOTA_MANAGER_H_
6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_ 6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/file_path.h" 18 #include "base/file_path.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
22 #include "base/sequenced_task_runner_helpers.h" 22 #include "base/sequenced_task_runner_helpers.h"
23 #include "webkit/quota/quota_client.h" 23 #include "webkit/quota/quota_client.h"
24 #include "webkit/quota/quota_database.h" 24 #include "webkit/quota/quota_database.h"
25 #include "webkit/quota/quota_task.h" 25 #include "webkit/quota/quota_task.h"
26 #include "webkit/quota/special_storage_policy.h" 26 #include "webkit/quota/special_storage_policy.h"
27 #include "webkit/storage/webkit_storage_export.h"
27 28
28 class FilePath; 29 class FilePath;
29 30
30 namespace base { 31 namespace base {
31 class SequencedTaskRunner; 32 class SequencedTaskRunner;
32 class SingleThreadTaskRunner; 33 class SingleThreadTaskRunner;
33 } 34 }
34 35
35 namespace quota_internals { 36 namespace quota_internals {
36 class QuotaInternalsProxy; 37 class QuotaInternalsProxy;
(...skipping 10 matching lines...) Expand all
47 struct QuotaManagerDeleter; 48 struct QuotaManagerDeleter;
48 49
49 struct QuotaAndUsage { 50 struct QuotaAndUsage {
50 int64 usage; 51 int64 usage;
51 int64 unlimited_usage; 52 int64 unlimited_usage;
52 int64 quota; 53 int64 quota;
53 int64 available_disk_space; 54 int64 available_disk_space;
54 }; 55 };
55 56
56 // An interface called by QuotaTemporaryStorageEvictor. 57 // An interface called by QuotaTemporaryStorageEvictor.
57 class QuotaEvictionHandler { 58 class WEBKIT_STORAGE_EXPORT QuotaEvictionHandler {
58 public: 59 public:
59 typedef base::Callback<void(const GURL&)> GetLRUOriginCallback; 60 typedef base::Callback<void(const GURL&)> GetLRUOriginCallback;
60 typedef StatusCallback EvictOriginDataCallback; 61 typedef StatusCallback EvictOriginDataCallback;
61 typedef base::Callback<void(QuotaStatusCode, 62 typedef base::Callback<void(QuotaStatusCode,
62 const QuotaAndUsage& quota_and_usage)> 63 const QuotaAndUsage& quota_and_usage)>
63 GetUsageAndQuotaForEvictionCallback; 64 GetUsageAndQuotaForEvictionCallback;
64 65
65 // Returns the least recently used origin. It might return empty 66 // Returns the least recently used origin. It might return empty
66 // GURL when there are no evictable origins. 67 // GURL when there are no evictable origins.
67 virtual void GetLRUOrigin( 68 virtual void GetLRUOrigin(
(...skipping 18 matching lines...) Expand all
86 type(type), 87 type(type),
87 usage(usage) {} 88 usage(usage) {}
88 std::string host; 89 std::string host;
89 StorageType type; 90 StorageType type;
90 int64 usage; 91 int64 usage;
91 }; 92 };
92 93
93 // The quota manager class. This class is instantiated per profile and 94 // The quota manager class. This class is instantiated per profile and
94 // held by the profile. With the exception of the constructor and the 95 // held by the profile. With the exception of the constructor and the
95 // proxy() method, all methods should only be called on the IO thread. 96 // proxy() method, all methods should only be called on the IO thread.
96 class QuotaManager : public QuotaTaskObserver, 97 class WEBKIT_STORAGE_EXPORT QuotaManager
97 public QuotaEvictionHandler, 98 : public QuotaTaskObserver,
98 public base::RefCountedThreadSafe< 99 public QuotaEvictionHandler,
99 QuotaManager, QuotaManagerDeleter> { 100 public base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter> {
100 public: 101 public:
101 typedef base::Callback<void(QuotaStatusCode, 102 typedef base::Callback<void(QuotaStatusCode,
102 int64 /* usage */, 103 int64 /* usage */,
103 int64 /* quota */)> 104 int64 /* quota */)>
104 GetUsageAndQuotaCallback; 105 GetUsageAndQuotaCallback;
105 static const int64 kNoLimit; 106 static const int64 kNoLimit;
106 107
107 QuotaManager(bool is_incognito, 108 QuotaManager(bool is_incognito,
108 const FilePath& profile_path, 109 const FilePath& profile_path,
109 base::SingleThreadTaskRunner* io_thread, 110 base::SingleThreadTaskRunner* io_thread,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // This is kept non-const so that test code can change the value. 209 // This is kept non-const so that test code can change the value.
209 // TODO(kinuko): Make this a real const value and add a proper way to set 210 // TODO(kinuko): Make this a real const value and add a proper way to set
210 // the quota for syncable storage. (http://crbug.com/155488) 211 // the quota for syncable storage. (http://crbug.com/155488)
211 static int64 kSyncableStorageDefaultHostQuota; 212 static int64 kSyncableStorageDefaultHostQuota;
212 213
213 protected: 214 protected:
214 virtual ~QuotaManager(); 215 virtual ~QuotaManager();
215 216
216 private: 217 private:
217 friend class base::DeleteHelper<QuotaManager>; 218 friend class base::DeleteHelper<QuotaManager>;
219 friend class base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter>;
218 friend class MockQuotaManager; 220 friend class MockQuotaManager;
219 friend class MockStorageClient; 221 friend class MockStorageClient;
220 friend class quota_internals::QuotaInternalsProxy; 222 friend class quota_internals::QuotaInternalsProxy;
221 friend class QuotaManagerProxy; 223 friend class QuotaManagerProxy;
222 friend class QuotaManagerTest; 224 friend class QuotaManagerTest;
223 friend class QuotaTemporaryStorageEvictor; 225 friend class QuotaTemporaryStorageEvictor;
224 friend struct QuotaManagerDeleter; 226 friend struct QuotaManagerDeleter;
225 227
226 class GetUsageInfoTask; 228 class GetUsageInfoTask;
227 class UsageAndQuotaDispatcherTask; 229 class UsageAndQuotaDispatcherTask;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 DISALLOW_COPY_AND_ASSIGN(QuotaManager); 413 DISALLOW_COPY_AND_ASSIGN(QuotaManager);
412 }; 414 };
413 415
414 struct QuotaManagerDeleter { 416 struct QuotaManagerDeleter {
415 static void Destruct(const QuotaManager* manager) { 417 static void Destruct(const QuotaManager* manager) {
416 manager->DeleteOnCorrectThread(); 418 manager->DeleteOnCorrectThread();
417 } 419 }
418 }; 420 };
419 421
420 // The proxy may be called and finally released on any thread. 422 // The proxy may be called and finally released on any thread.
421 class QuotaManagerProxy 423 class WEBKIT_STORAGE_EXPORT QuotaManagerProxy
422 : public base::RefCountedThreadSafe<QuotaManagerProxy> { 424 : public base::RefCountedThreadSafe<QuotaManagerProxy> {
423 public: 425 public:
424 virtual void RegisterClient(QuotaClient* client); 426 virtual void RegisterClient(QuotaClient* client);
425 virtual void NotifyStorageAccessed(QuotaClient::ID client_id, 427 virtual void NotifyStorageAccessed(QuotaClient::ID client_id,
426 const GURL& origin, 428 const GURL& origin,
427 StorageType type); 429 StorageType type);
428 virtual void NotifyStorageModified(QuotaClient::ID client_id, 430 virtual void NotifyStorageModified(QuotaClient::ID client_id,
429 const GURL& origin, 431 const GURL& origin,
430 StorageType type, 432 StorageType type,
431 int64 delta); 433 int64 delta);
(...skipping 14 matching lines...) Expand all
446 448
447 QuotaManager* manager_; // only accessed on the io thread 449 QuotaManager* manager_; // only accessed on the io thread
448 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; 450 scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
449 451
450 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); 452 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy);
451 }; 453 };
452 454
453 } // namespace quota 455 } // namespace quota
454 456
455 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ 457 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_
OLDNEW
« no previous file with comments | « webkit/quota/quota_database.h ('k') | webkit/quota/quota_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698