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_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 #include <set> |
| 11 #include <string> |
| 12 #include <vector> |
| 13 |
| 14 #include "base/memory/ref_counted.h" |
| 15 #include "content/browser/browser_thread.h" |
| 16 #include "webkit/quota/quota_manager.h" |
| 17 #include "webkit/quota/quota_types.h" |
| 18 |
| 19 namespace quota_internals { |
| 20 |
| 21 class QuotaInternalsHandler; |
| 22 class GlobalStorageInfo; |
| 23 class PerHostStorageInfo; |
| 24 class PerOriginStorageInfo; |
| 25 typedef std::map<std::string, std::string> Statistics; |
| 26 |
| 27 // This class is the bridge between QuotaInternalsHandler and QuotaManager. |
| 28 // Each QuotaInternalsHandler instances creates and owns a instance of this |
| 29 // class. |
| 30 class QuotaInternalsProxy |
| 31 : public base::RefCountedThreadSafe<QuotaInternalsProxy, |
| 32 BrowserThread::DeleteOnIOThread> { |
| 33 public: |
| 34 explicit QuotaInternalsProxy(QuotaInternalsHandler* handler); |
| 35 ~QuotaInternalsProxy(); |
| 36 |
| 37 void RequestInfo(scoped_refptr<quota::QuotaManager> quota_manager); |
| 38 |
| 39 private: |
| 40 typedef quota::QuotaManager::QuotaTableEntries QuotaTableEntries; |
| 41 typedef quota::QuotaManager::OriginInfoTableEntries OriginInfoTableEntries; |
| 42 |
| 43 void ReportAvailableSpace(int64 available_space); |
| 44 void ReportGlobalInfo(const GlobalStorageInfo& data); |
| 45 void ReportPerHostInfo(const std::vector<PerHostStorageInfo>& hosts); |
| 46 void ReportPerOriginInfo(const std::vector<PerOriginStorageInfo>& origins); |
| 47 void ReportStatistics(const Statistics& stats); |
| 48 |
| 49 // Called on IO Thread by QuotaManager as callback. |
| 50 void DidGetAvailableSpace(quota::QuotaStatusCode status, int64 space); |
| 51 void DidGetGlobalQuota(quota::QuotaStatusCode status, |
| 52 quota::StorageType type, |
| 53 int64 quota); |
| 54 void DidGetGlobalUsage(quota::StorageType type, |
| 55 int64 usage, |
| 56 int64 unlimited_usage); |
| 57 void DidDumpQuotaTable(const QuotaTableEntries& entries); |
| 58 void DidDumpOriginInfoTable(const OriginInfoTableEntries& entries); |
| 59 void DidGetHostUsage(const std::string& host, |
| 60 quota::StorageType type, |
| 61 int64 usage); |
| 62 |
| 63 // Helper. Called on IO Thread. |
| 64 void RequestPerOriginInfo(quota::StorageType type); |
| 65 void VisitHost(const std::string& host, quota::StorageType type); |
| 66 void GetHostUsage(const std::string& host, quota::StorageType type); |
| 67 |
| 68 // Used on UI Thread. |
| 69 QuotaInternalsHandler* handler_; |
| 70 |
| 71 // Used on IO Thread. |
| 72 base::ScopedCallbackFactory<QuotaInternalsProxy> callback_factory_; |
| 73 scoped_refptr<quota::QuotaManager> quota_manager_; |
| 74 std::set<std::pair<std::string, quota::StorageType> > |
| 75 hosts_visited_, hosts_pending_; |
| 76 std::vector<PerHostStorageInfo> report_pending_; |
| 77 |
| 78 friend class QuotaInternalsHandler; |
| 79 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
| 80 friend class DeleteTask<QuotaInternalsProxy>; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(QuotaInternalsProxy); |
| 83 }; |
| 84 } // quota_internals |
| 85 |
| 86 #endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_PROXY_H_ |
OLD | NEW |