| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSING_DATA_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // Clients may remove an origin's file systems at any time (even before fetching | 39 // Clients may remove an origin's file systems at any time (even before fetching |
| 40 // data) by calling DeleteFileSystemOrigin() on the UI thread. Calling | 40 // data) by calling DeleteFileSystemOrigin() on the UI thread. Calling |
| 41 // DeleteFileSystemOrigin() for an origin that doesn't have any is safe; it's | 41 // DeleteFileSystemOrigin() for an origin that doesn't have any is safe; it's |
| 42 // just an expensive NOOP. | 42 // just an expensive NOOP. |
| 43 class BrowsingDataFileSystemHelper | 43 class BrowsingDataFileSystemHelper |
| 44 : public base::RefCountedThreadSafe<BrowsingDataFileSystemHelper> { | 44 : public base::RefCountedThreadSafe<BrowsingDataFileSystemHelper> { |
| 45 public: | 45 public: |
| 46 // Detailed information about a file system, including it's origin GURL, | 46 // Detailed information about a file system, including it's origin GURL, |
| 47 // the amount of data (in bytes) for each sandboxed filesystem type. | 47 // the amount of data (in bytes) for each sandboxed filesystem type. |
| 48 struct FileSystemInfo { | 48 struct FileSystemInfo { |
| 49 FileSystemInfo(const GURL& origin); | 49 explicit FileSystemInfo(const GURL& origin); |
| 50 ~FileSystemInfo(); | 50 ~FileSystemInfo(); |
| 51 | 51 |
| 52 // The origin for which the information is relevant. | 52 // The origin for which the information is relevant. |
| 53 GURL origin; | 53 GURL origin; |
| 54 // FileSystemType to usage (in bytes) map. | 54 // FileSystemType to usage (in bytes) map. |
| 55 std::map<fileapi::FileSystemType, int64> usage_map; | 55 std::map<fileapi::FileSystemType, int64> usage_map; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // Creates a BrowsingDataFileSystemHelper instance for the file systems | 58 // Creates a BrowsingDataFileSystemHelper instance for the file systems |
| 59 // stored in |profile|'s user data directory. The BrowsingDataFileSystemHelper | 59 // stored in |profile|'s user data directory. The BrowsingDataFileSystemHelper |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // class. It hasn't been necessary for anything that uses the canned | 137 // class. It hasn't been necessary for anything that uses the canned |
| 138 // implementation, as the canned class is only used in tests, or in read-only | 138 // implementation, as the canned class is only used in tests, or in read-only |
| 139 // contexts (like the non-modal cookie dialog). | 139 // contexts (like the non-modal cookie dialog). |
| 140 virtual void DeleteFileSystemOrigin(const GURL& origin) OVERRIDE {} | 140 virtual void DeleteFileSystemOrigin(const GURL& origin) OVERRIDE {} |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 // Used by Clone() to create an object without a Profile | 143 // Used by Clone() to create an object without a Profile |
| 144 CannedBrowsingDataFileSystemHelper(); | 144 CannedBrowsingDataFileSystemHelper(); |
| 145 virtual ~CannedBrowsingDataFileSystemHelper(); | 145 virtual ~CannedBrowsingDataFileSystemHelper(); |
| 146 | 146 |
| 147 // Triggers the success callback as the end of a StartFetching workflow. This | |
| 148 // must be called on the UI thread. | |
| 149 void NotifyOnUIThread(); | |
| 150 | |
| 151 // Holds the current list of filesystems returned to the client. Access to | 147 // Holds the current list of filesystems returned to the client. Access to |
| 152 // |file_system_info_| is triggered indirectly via the UI thread and guarded | 148 // |file_system_info_| is triggered indirectly via the UI thread and guarded |
| 153 // by |is_fetching_|. This means |file_system_info_| is only accessed while | 149 // by |is_fetching_|. This means |file_system_info_| is only accessed while |
| 154 // |is_fetching_| is true. The flag |is_fetching_| is only accessed on the UI | 150 // |is_fetching_| is true. The flag |is_fetching_| is only accessed on the UI |
| 155 // thread. | 151 // thread. |
| 156 std::list<FileSystemInfo> file_system_info_; | 152 std::list<FileSystemInfo> file_system_info_; |
| 157 | 153 |
| 158 // The callback passed in at the beginning of the StartFetching workflow so | 154 // The callback passed in at the beginning of the StartFetching workflow so |
| 159 // that it can be triggered via NotifyOnUIThread. | 155 // that it can be triggered via NotifyOnUIThread. |
| 160 base::Callback<void(const std::list<FileSystemInfo>&)> completion_callback_; | 156 base::Callback<void(const std::list<FileSystemInfo>&)> completion_callback_; |
| 161 | 157 |
| 162 // Indicates whether or not we're currently fetching information: set to true | 158 // Indicates whether or not we're currently fetching information: set to true |
| 163 // when StartFetching is called on the UI thread, and reset to false when | 159 // when StartFetching is called on the UI thread, and reset to false when |
| 164 // NotifyOnUIThread triggers the success callback. | 160 // NotifyOnUIThread triggers the success callback. |
| 165 // This property only mutates on the UI thread. | 161 // This property only mutates on the UI thread. |
| 166 bool is_fetching_; | 162 bool is_fetching_; |
| 167 | 163 |
| 168 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataFileSystemHelper); | 164 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataFileSystemHelper); |
| 169 }; | 165 }; |
| 170 | 166 |
| 171 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ | 167 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ |
| OLD | NEW |