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