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_IMPL_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 #include <set> |
| 11 #include <string> |
| 12 #include <utility> |
| 13 #include <vector> |
| 14 |
| 15 #include "base/callback_old.h" |
| 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_callback_factory.h" |
| 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/time.h" |
| 20 #include "chrome/browser/browsing_data_quota_helper.h" |
| 21 #include "content/browser/browser_thread.h" |
| 22 #include "webkit/quota/quota_types.h" |
| 23 |
| 24 namespace quota { |
| 25 class QuotaManager; |
| 26 } |
| 27 |
| 28 // Implementation of BrowsingDataQuotaHelper. Since a client of |
| 29 // BrowsingDataQuotaHelper should live in UI thread and QuotaManager lives in |
| 30 // IO thread, we have to communicate over thread using PostTask. |
| 31 class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper { |
| 32 public: |
| 33 virtual void StartFetching(FetchResultCallback* callback) OVERRIDE; |
| 34 virtual void CancelNotification() OVERRIDE; |
| 35 |
| 36 private: |
| 37 void FetchQuotaInfo(); |
| 38 void OnComplete(); |
| 39 |
| 40 void GetHostUsage(const std::string& host, quota::StorageType type); |
| 41 void ProcessPendingHosts(); |
| 42 |
| 43 // Callback function for GetOriginModifiedSince. |
| 44 void GotOrigins(const std::set<GURL>& origins, quota::StorageType type); |
| 45 |
| 46 // Callback function for GetHostUsage. |
| 47 void GotHostUsage(const std::string& host, |
| 48 quota::StorageType type, |
| 49 int64 usage); |
| 50 |
| 51 explicit BrowsingDataQuotaHelperImpl(base::MessageLoopProxy* ui_thread, |
| 52 base::MessageLoopProxy* io_thread, |
| 53 quota::QuotaManager* quota_manager); |
| 54 virtual ~BrowsingDataQuotaHelperImpl(); |
| 55 |
| 56 scoped_refptr<quota::QuotaManager> quota_manager_; |
| 57 scoped_ptr<FetchResultCallback> callback_; |
| 58 |
| 59 typedef std::set<std::pair<std::string, quota::StorageType> > PendingHosts; |
| 60 PendingHosts pending_hosts_; |
| 61 std::map<std::string, QuotaInfo> quota_info_; |
| 62 |
| 63 bool is_fetching_; |
| 64 |
| 65 scoped_refptr<base::MessageLoopProxy> ui_thread_; |
| 66 scoped_refptr<base::MessageLoopProxy> io_thread_; |
| 67 base::ScopedCallbackFactory<BrowsingDataQuotaHelperImpl> callback_factory_; |
| 68 |
| 69 friend class BrowsingDataQuotaHelper; |
| 70 friend class BrowsingDataQuotaHelperTest; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperImpl); |
| 73 }; |
| 74 |
| 75 #endif // CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_ |
OLD | NEW |