| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 #include "webkit/common/fileapi/file_system_types.h" | 19 #include "storage/common/fileapi/file_system_types.h" |
| 20 | 20 |
| 21 namespace fileapi { | 21 namespace storage { |
| 22 class FileSystemContext; | 22 class FileSystemContext; |
| 23 } | 23 } |
| 24 | 24 |
| 25 class Profile; | 25 class Profile; |
| 26 | 26 |
| 27 // Defines an interface for classes that deal with aggregating and deleting | 27 // Defines an interface for classes that deal with aggregating and deleting |
| 28 // browsing data stored in an origin's file systems. | 28 // browsing data stored in an origin's file systems. |
| 29 // BrowsingDataFileSystemHelper instances for a specific profile should be | 29 // BrowsingDataFileSystemHelper instances for a specific profile should be |
| 30 // created via the static Create method. Each instance will lazily fetch file | 30 // created via the static Create method. Each instance will lazily fetch file |
| 31 // system data when a client calls StartFetching from the UI thread, and will | 31 // system data when a client calls StartFetching from the UI thread, and will |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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 explicit 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<storage::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 |
| 60 // object will hold a reference to the Profile that's passed in, but is not | 60 // object will hold a reference to the Profile that's passed in, but is not |
| 61 // responsible for destroying it. | 61 // responsible for destroying it. |
| 62 // | 62 // |
| 63 // The BrowsingDataFileSystemHelper will not change the profile itself, but | 63 // The BrowsingDataFileSystemHelper will not change the profile itself, but |
| 64 // can modify data it contains (by removing file systems). | 64 // can modify data it contains (by removing file systems). |
| 65 static BrowsingDataFileSystemHelper* Create( | 65 static BrowsingDataFileSystemHelper* Create( |
| 66 fileapi::FileSystemContext* file_system_context); | 66 storage::FileSystemContext* file_system_context); |
| 67 | 67 |
| 68 // Starts the process of fetching file system data, which will call |callback| | 68 // Starts the process of fetching file system data, which will call |callback| |
| 69 // upon completion, passing it a constant list of FileSystemInfo objects. | 69 // upon completion, passing it a constant list of FileSystemInfo objects. |
| 70 // StartFetching must be called only in the UI thread; the provided Callback1 | 70 // StartFetching must be called only in the UI thread; the provided Callback1 |
| 71 // will likewise be executed asynchronously on the UI thread. | 71 // will likewise be executed asynchronously on the UI thread. |
| 72 // | 72 // |
| 73 // BrowsingDataFileSystemHelper takes ownership of the Callback1, and is | 73 // BrowsingDataFileSystemHelper takes ownership of the Callback1, and is |
| 74 // responsible for deleting it once it's no longer needed. | 74 // responsible for deleting it once it's no longer needed. |
| 75 virtual void StartFetching(const base::Callback< | 75 virtual void StartFetching(const base::Callback< |
| 76 void(const std::list<FileSystemInfo>&)>& callback) = 0; | 76 void(const std::list<FileSystemInfo>&)>& callback) = 0; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 105 // Clone() is safe to call while StartFetching() is running. Clients of the | 105 // Clone() is safe to call while StartFetching() is running. Clients of the |
| 106 // newly created object must themselves execute StartFetching(), however: the | 106 // newly created object must themselves execute StartFetching(), however: the |
| 107 // copy will not have a pending fetch. | 107 // copy will not have a pending fetch. |
| 108 CannedBrowsingDataFileSystemHelper* Clone(); | 108 CannedBrowsingDataFileSystemHelper* Clone(); |
| 109 | 109 |
| 110 // Manually adds a filesystem to the set of canned file systems that this | 110 // Manually adds a filesystem to the set of canned file systems that this |
| 111 // helper returns via StartFetching. If an origin contains both a temporary | 111 // helper returns via StartFetching. If an origin contains both a temporary |
| 112 // and a persistent filesystem, AddFileSystem must be called twice (once for | 112 // and a persistent filesystem, AddFileSystem must be called twice (once for |
| 113 // each file system type). | 113 // each file system type). |
| 114 void AddFileSystem(const GURL& origin, | 114 void AddFileSystem(const GURL& origin, |
| 115 fileapi::FileSystemType type, | 115 storage::FileSystemType type, |
| 116 int64 size); | 116 int64 size); |
| 117 | 117 |
| 118 // Clear this helper's list of canned filesystems. | 118 // Clear this helper's list of canned filesystems. |
| 119 void Reset(); | 119 void Reset(); |
| 120 | 120 |
| 121 // True if no filesystems are currently stored. | 121 // True if no filesystems are currently stored. |
| 122 bool empty() const; | 122 bool empty() const; |
| 123 | 123 |
| 124 // Returns the number of currently stored filesystems. | 124 // Returns the number of currently stored filesystems. |
| 125 size_t GetFileSystemCount() const; | 125 size_t GetFileSystemCount() const; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 148 std::list<FileSystemInfo> file_system_info_; | 148 std::list<FileSystemInfo> file_system_info_; |
| 149 | 149 |
| 150 // The callback passed in at the beginning of the StartFetching workflow so | 150 // The callback passed in at the beginning of the StartFetching workflow so |
| 151 // that it can be triggered via NotifyOnUIThread. | 151 // that it can be triggered via NotifyOnUIThread. |
| 152 base::Callback<void(const std::list<FileSystemInfo>&)> completion_callback_; | 152 base::Callback<void(const std::list<FileSystemInfo>&)> completion_callback_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataFileSystemHelper); | 154 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataFileSystemHelper); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ | 157 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ |
| OLD | NEW |