Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_ | |
| 6 #define CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/callback_old.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/time.h" | |
| 15 #include "content/browser/browser_thread.h" | |
| 16 #include "webkit/quota/quota_types.h" | |
| 17 | |
| 18 class Profile; | |
| 19 | |
| 20 namespace quota { | |
| 21 class QuotaManager; | |
| 22 } | |
| 23 | |
| 24 // This class is an interface class to bridge between Cookies Tree and Unified | |
| 25 // Quota System. This class provides a way to get usage and quota information | |
| 26 // through the instance. | |
| 27 // | |
| 28 // Call Create to create an instance for a profile and call StartFetching with | |
| 29 // a callback to fetch information asynchronously. If result is no longer needed | |
| 30 // after StartFetching, call CancelNotification to prevent callback. | |
| 31 // | |
| 32 // Parallel fetching is not allowed, a fetching task should start after end of | |
| 33 // previous task. All method of this class should called from UI thread. | |
| 34 // | |
| 35 // QuotaInfo contains host-based quota and usage informations for persistent | |
|
kinuko
2011/07/25 13:22:41
nit: should this comment be moved at the definitio
tzik
2011/07/26 10:52:41
Done.
| |
| 36 // and temporary storage. | |
| 37 class BrowsingDataQuotaHelper | |
| 38 : public base::RefCountedThreadSafe<BrowsingDataQuotaHelper, | |
| 39 BrowserThread::DeleteOnIOThread> { | |
|
kinuko
2011/07/25 13:22:41
As we chatted locally, we should either 1) use Mes
tzik
2011/07/26 10:52:41
Done.
I modified them as 1).
We can easily switch
| |
| 40 public: | |
| 41 struct QuotaInfo { | |
| 42 QuotaInfo(); | |
| 43 explicit QuotaInfo(const std::string& host); | |
| 44 QuotaInfo(const std::string& host, | |
| 45 int64 temporary_usage, | |
| 46 int64 persistent_usage, | |
| 47 int64 persistent_quota); | |
| 48 ~QuotaInfo(); | |
| 49 | |
| 50 std::string host; | |
| 51 int64 temporary_usage; | |
| 52 int64 persistent_usage; | |
| 53 int64 persistent_quota; | |
| 54 }; | |
| 55 | |
| 56 typedef std::vector<QuotaInfo> QuotaInfoList; | |
| 57 typedef Callback1<const QuotaInfoList&>::Type FetchResultCallback; | |
| 58 | |
| 59 static BrowsingDataQuotaHelper* Create(Profile* profile); | |
| 60 | |
| 61 virtual void StartFetching(FetchResultCallback* callback) = 0; | |
| 62 virtual void CancelNotification() = 0; | |
| 63 | |
| 64 // We don't support deletion now. | |
| 65 virtual void DeleteQuotaHost(const std::string& host) {} | |
| 66 | |
| 67 protected: | |
| 68 BrowsingDataQuotaHelper() { } | |
| 69 virtual ~BrowsingDataQuotaHelper() { } | |
|
kinuko
2011/07/25 13:22:41
no space between { } ?
tzik
2011/07/26 10:52:41
Done.
| |
| 70 | |
| 71 private: | |
| 72 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | |
| 73 friend class DeleteTask<BrowsingDataQuotaHelper>; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelper); | |
| 76 }; | |
| 77 | |
| 78 bool operator <(const BrowsingDataQuotaHelper::QuotaInfo& lhs, | |
| 79 const BrowsingDataQuotaHelper::QuotaInfo& rhs); | |
| 80 bool operator ==(const BrowsingDataQuotaHelper::QuotaInfo& lhs, | |
|
kinuko
2011/07/25 13:22:41
Is this really necessary? (Just asking)
tzik
2011/07/26 10:52:41
We need it for
browsing_data_quota_helper_unittest
| |
| 81 const BrowsingDataQuotaHelper::QuotaInfo& rhs); | |
| 82 | |
| 83 #endif // CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_ | |
| OLD | NEW |