Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h

Issue 2123133002: Storage manager: Add site data size on the amount of browsing data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a missing header. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_STORAGE_MANAGER_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_STORAGE_MANAGER_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_STORAGE_MANAGER_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_STORAGE_MANAGER_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map>
11 #include <memory>
10 #include <vector> 12 #include <vector>
11 13
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/browsing_data/site_data_size_collector.h"
14 #include "chrome/browser/ui/webui/options/options_ui.h" 17 #include "chrome/browser/ui/webui/options/options_ui.h"
15 #include "components/arc/storage_manager/arc_storage_manager.h" 18 #include "components/arc/storage_manager/arc_storage_manager.h"
16 #include "components/user_manager/user.h" 19 #include "components/user_manager/user.h"
17 20
18 namespace chromeos { 21 namespace chromeos {
19 namespace options { 22 namespace options {
20 23
21 // Storage manager overlay page UI handler. 24 // Storage manager overlay page UI handler.
22 class StorageManagerHandler : public ::options::OptionsPageUIHandler { 25 class StorageManagerHandler : public ::options::OptionsPageUIHandler {
23 public: 26 public:
24 // Enumeration for device state about remaining space. These values must be 27 // Enumeration for device state about remaining space. These values must be
25 // kept in sync with options.StorageSpaceState in JS code. 28 // kept in sync with options.StorageSpaceState in JS code.
26 enum StorageSpaceState { 29 enum StorageSpaceState {
27 STORAGE_SPACE_NORMAL = 0, 30 STORAGE_SPACE_NORMAL = 0,
28 STORAGE_SPACE_LOW = 1, 31 STORAGE_SPACE_LOW = 1,
29 STORAGE_SPACE_CRITICALLY_LOW = 2, 32 STORAGE_SPACE_CRITICALLY_LOW = 2,
30 }; 33 };
31 34
32 StorageManagerHandler(); 35 StorageManagerHandler();
33 ~StorageManagerHandler() override; 36 ~StorageManagerHandler() override;
34 37
35 // OptionsPageUIHandler implementation. 38 // OptionsPageUIHandler implementation.
36 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; 39 void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
37 void InitializePage() override; 40 void InitializePage() override;
38 41
39 // WebUIMessageHandler implementation. 42 // WebUIMessageHandler implementation.
40 void RegisterMessages() override; 43 void RegisterMessages() override;
41 44
42 private: 45 private:
46 // Enumlation for types of browsing data which we aocunt.
47 enum BrowsingDataType {
48 BROWSING_DATA_TYPE_HTTP_CACHE = 0,
49 BROWSING_DATA_TYPE_SITE_DATA,
50 BROWSING_DATA_TYPE_MAX
51 };
52
43 // Handlers of JS messages. 53 // Handlers of JS messages.
44 void HandleUpdateStorageInfo(const base::ListValue* unused_args); 54 void HandleUpdateStorageInfo(const base::ListValue* unused_args);
45 void HandleOpenDownloads(const base::ListValue* unused_args); 55 void HandleOpenDownloads(const base::ListValue* unused_args);
46 void HandleOpenArcStorage(const base::ListValue* unused_args); 56 void HandleOpenArcStorage(const base::ListValue* unused_args);
47 void HandleClearDriveCache(const base::ListValue* unused_args); 57 void HandleClearDriveCache(const base::ListValue* unused_args);
48 58
49 // Requests updating disk space information. 59 // Requests updating disk space information.
50 void UpdateSizeStat(); 60 void UpdateSizeStat();
51 61
52 // Callback to update the UI about disk space information. 62 // Callback to update the UI about disk space information.
53 void OnGetSizeStat(int64_t* total_size, int64_t* available_size); 63 void OnGetSizeStat(int64_t* total_size, int64_t* available_size);
54 64
55 // Requests updating the size of Downloads directory. 65 // Requests updating the size of Downloads directory.
56 void UpdateDownloadsSize(); 66 void UpdateDownloadsSize();
57 67
58 // Callback to update the UI about the size of Downloads directory. 68 // Callback to update the UI about the size of Downloads directory.
59 void OnGetDownloadsSize(int64_t size); 69 void OnGetDownloadsSize(int64_t size);
60 70
61 // Requests updating the size of Drive Cache. 71 // Requests updating the size of Drive Cache.
62 void UpdateDriveCacheSize(); 72 void UpdateDriveCacheSize();
63 73
64 // Callback to update the UI about the size of Drive Cache. 74 // Callback to update the UI about the size of Drive Cache.
65 void OnGetDriveCacheSize(int64_t size); 75 void OnGetDriveCacheSize(int64_t size);
66 76
67 // Requests updating the size of browsing data. 77 // Requests updating the size of browsing data.
68 void UpdateBrowsingDataSize(); 78 void UpdateBrowsingDataSize();
69 79
70 // Callback to update the UI about the size of browsing data. 80 // Callback to update the UI about the size of browsing data.
71 void OnGetBrowsingDataSize(bool is_site_data, int64_t size); 81 void OnGetBrowsingDataSize(BrowsingDataType, int64_t size);
72 82
73 // Requests updating the total size of other users' data. 83 // Requests updating the total size of other users' data.
74 void UpdateOtherUsersSize(); 84 void UpdateOtherUsersSize();
75 85
76 // Callback to save the fetched user sizes and update the UI. 86 // Callback to save the fetched user sizes and update the UI.
77 void OnGetOtherUserSize(bool success, int64_t size); 87 void OnGetOtherUserSize(bool success, int64_t size);
78 88
79 // Requests updating the space size used by Android apps and cache. 89 // Requests updating the space size used by Android apps and cache.
80 void UpdateArcSize(); 90 void UpdateArcSize();
81 91
82 // Callback to update the UI about Android apps and cache. 92 // Callback to update the UI about Android apps and cache.
83 void OnGetArcSize(bool succeeded, arc::mojom::ApplicationsSizePtr size); 93 void OnGetArcSize(bool succeeded, arc::mojom::ApplicationsSizePtr size);
84 94
85 // Callback called when clearing Drive cache is done. 95 // Callback called when clearing Drive cache is done.
86 void OnClearDriveCacheDone(bool success); 96 void OnClearDriveCacheDone(bool success);
87 97
88 // Total size of cache data in browsing data. 98 // Map to store fetched size of browsing data.
89 int64_t browser_cache_size_; 99 std::map<BrowsingDataType, int64_t> browsing_data_size_;
90
91 // Total size of site data in browsing data.
92 int64_t browser_site_data_size_;
93 100
94 // The list of other users whose directory sizes will be accumulated as the 101 // The list of other users whose directory sizes will be accumulated as the
95 // size of "Other users". 102 // size of "Other users".
96 user_manager::UserList other_users_; 103 user_manager::UserList other_users_;
97 104
98 // Fetched sizes of user directories. 105 // Fetched sizes of user directories.
99 std::vector<int64_t> user_sizes_; 106 std::vector<int64_t> user_sizes_;
100 107
108 // Helper to compute the total size of all types of site date.
109 std::unique_ptr<SiteDataSizeCollector> site_data_size_collector_;
110
101 base::WeakPtrFactory<StorageManagerHandler> weak_ptr_factory_; 111 base::WeakPtrFactory<StorageManagerHandler> weak_ptr_factory_;
102 112
103 DISALLOW_COPY_AND_ASSIGN(StorageManagerHandler); 113 DISALLOW_COPY_AND_ASSIGN(StorageManagerHandler);
104 }; 114 };
105 115
106 } // namespace options 116 } // namespace options
107 } // namespace chromeos 117 } // namespace chromeos
108 118
109 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_STORAGE_MANAGER_HANDLER_H_ 119 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_STORAGE_MANAGER_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698