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_QUOTA_INTERNALS_TYPES_H_ 6 #define CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_QUOTA_INTERNALS_TYPES_H_ 7 8 #include <map> 9 #include <string> 10 11 #include "base/time/time.h" 12 #include "storage/common/quota/quota_types.h" 13 #include "url/gurl.h" 14 15 namespace base { 16 class Value; 17 } 18 19 namespace quota_internals { 20 21 // Represends global usage and quota information for specific type of storage. 22 class GlobalStorageInfo { 23 public: 24 explicit GlobalStorageInfo(storage::StorageType type); 25 ~GlobalStorageInfo(); 26 27 void set_usage(int64 usage) { 28 usage_ = usage; 29 } 30 31 void set_unlimited_usage(int64 unlimited_usage) { 32 unlimited_usage_ = unlimited_usage; 33 } 34 35 void set_quota(int64 quota) { 36 quota_ = quota; 37 } 38 39 // Create new Value for passing to WebUI page. Caller is responsible for 40 // deleting the returned pointer. 41 base::Value* NewValue() const; 42 private: 43 storage::StorageType type_; 44 45 int64 usage_; 46 int64 unlimited_usage_; 47 int64 quota_; 48 }; 49 50 // Represents per host usage and quota information for the storage. 51 class PerHostStorageInfo { 52 public: 53 PerHostStorageInfo(const std::string& host, storage::StorageType type); 54 ~PerHostStorageInfo(); 55 56 void set_usage(int64 usage) { 57 usage_ = usage; 58 } 59 60 void set_quota(int64 quota) { 61 quota_ = quota; 62 } 63 64 // Create new Value for passing to WebUI page. Caller is responsible for 65 // deleting the returned pointer. 66 base::Value* NewValue() const; 67 private: 68 std::string host_; 69 storage::StorageType type_; 70 71 int64 usage_; 72 int64 quota_; 73 }; 74 75 // Represendts per origin usage and access time information. 76 class PerOriginStorageInfo { 77 public: 78 PerOriginStorageInfo(const GURL& origin, storage::StorageType type); 79 ~PerOriginStorageInfo(); 80 81 void set_in_use(bool in_use) { 82 in_use_ = in_use ? 1 : 0; 83 } 84 85 void set_used_count(int used_count) { 86 used_count_ = used_count; 87 } 88 89 void set_last_access_time(base::Time last_access_time) { 90 last_access_time_ = last_access_time; 91 } 92 93 void set_last_modified_time(base::Time last_modified_time) { 94 last_modified_time_ = last_modified_time; 95 } 96 97 // Create new Value for passing to WebUI page. Caller is responsible for 98 // deleting the returned pointer. 99 base::Value* NewValue() const; 100 private: 101 GURL origin_; 102 storage::StorageType type_; 103 std::string host_; 104 105 int in_use_; 106 int used_count_; 107 base::Time last_access_time_; 108 base::Time last_modified_time_; 109 }; 110 } // namespace quota_internals 111 112 #endif // CHROME_BROWSER_UI_WEBUI_QUOTA_INTERNALS_QUOTA_INTERNALS_TYPES_H_ 113