OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_FILE_SYSTEM_HELPER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback_old.h" | 12 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" |
13 #include "base/file_path.h" | 14 #include "base/file_path.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
17 #include "base/time.h" | 18 #include "base/time.h" |
18 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
20 #include "webkit/fileapi/file_system_types.h" | 21 #include "webkit/fileapi/file_system_types.h" |
21 | 22 |
22 class Profile; | 23 class Profile; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // can modify data it contains (by removing file systems). | 76 // can modify data it contains (by removing file systems). |
76 static BrowsingDataFileSystemHelper* Create(Profile* profile); | 77 static BrowsingDataFileSystemHelper* Create(Profile* profile); |
77 | 78 |
78 // Starts the process of fetching file system data, which will call |callback| | 79 // Starts the process of fetching file system data, which will call |callback| |
79 // upon completion, passing it a constant list of FileSystemInfo objects. | 80 // upon completion, passing it a constant list of FileSystemInfo objects. |
80 // StartFetching must be called only in the UI thread; the provided Callback1 | 81 // StartFetching must be called only in the UI thread; the provided Callback1 |
81 // will likewise be executed asynchronously on the UI thread. | 82 // will likewise be executed asynchronously on the UI thread. |
82 // | 83 // |
83 // BrowsingDataFileSystemHelper takes ownership of the Callback1, and is | 84 // BrowsingDataFileSystemHelper takes ownership of the Callback1, and is |
84 // responsible for deleting it once it's no longer needed. | 85 // responsible for deleting it once it's no longer needed. |
85 virtual void StartFetching( | 86 virtual void StartFetching(const base::Callback< |
86 Callback1<const std::list<FileSystemInfo>& >::Type* callback) = 0; | 87 void(const std::list<FileSystemInfo>&)>& callback) = 0; |
87 | 88 |
88 // Cancels the notification callback associated with StartFetching. Clients | 89 // Cancels the notification callback associated with StartFetching. Clients |
89 // that are destroyed before the callback is triggered must call this, and | 90 // that are destroyed before the callback is triggered must call this, and |
90 // it must be called only on the UI thread. | 91 // it must be called only on the UI thread. |
91 virtual void CancelNotification() = 0; | 92 virtual void CancelNotification() = 0; |
92 | 93 |
93 // Deletes any temporary or persistent file systems associated with |origin| | 94 // Deletes any temporary or persistent file systems associated with |origin| |
94 // from the disk. Deletion will occur asynchronously on the FILE thread, but | 95 // from the disk. Deletion will occur asynchronously on the FILE thread, but |
95 // this function must be called only on the UI thread. | 96 // this function must be called only on the UI thread. |
96 virtual void DeleteFileSystemOrigin(const GURL& origin) = 0; | 97 virtual void DeleteFileSystemOrigin(const GURL& origin) = 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 void AddFileSystem(const GURL& origin, | 130 void AddFileSystem(const GURL& origin, |
130 fileapi::FileSystemType type, | 131 fileapi::FileSystemType type, |
131 int64 size); | 132 int64 size); |
132 | 133 |
133 // Clear this helper's list of canned filesystems. | 134 // Clear this helper's list of canned filesystems. |
134 void Reset(); | 135 void Reset(); |
135 | 136 |
136 // True if no filesystems are currently stored. | 137 // True if no filesystems are currently stored. |
137 bool empty() const; | 138 bool empty() const; |
138 | 139 |
139 // BrowsingDataFileSystemHelper methods. | 140 // BrowsingDataFileSystemHelper implementation. |
140 virtual void StartFetching( | 141 virtual void StartFetching(const base::Callback< |
141 Callback1<const std::list<FileSystemInfo>& >::Type* callback); | 142 void(const std::list<FileSystemInfo>&)>& callback) OVERRIDE; |
142 virtual void CancelNotification(); | 143 virtual void CancelNotification() OVERRIDE; |
143 | 144 |
144 // Note that this doesn't actually have an implementation for this canned | 145 // Note that this doesn't actually have an implementation for this canned |
145 // class. It hasn't been necessary for anything that uses the canned | 146 // class. It hasn't been necessary for anything that uses the canned |
146 // implementation, as the canned class is only used in tests, or in read-only | 147 // implementation, as the canned class is only used in tests, or in read-only |
147 // contexts (like the non-modal cookie dialog). | 148 // contexts (like the non-modal cookie dialog). |
148 virtual void DeleteFileSystemOrigin(const GURL& origin) {} | 149 virtual void DeleteFileSystemOrigin(const GURL& origin) OVERRIDE {} |
149 | 150 |
150 private: | 151 private: |
151 // Used by Clone() to create an object without a Profile | 152 // Used by Clone() to create an object without a Profile |
152 CannedBrowsingDataFileSystemHelper(); | 153 CannedBrowsingDataFileSystemHelper(); |
153 virtual ~CannedBrowsingDataFileSystemHelper(); | 154 virtual ~CannedBrowsingDataFileSystemHelper(); |
154 | 155 |
155 // Triggers the success callback as the end of a StartFetching workflow. This | 156 // Triggers the success callback as the end of a StartFetching workflow. This |
156 // must be called on the UI thread. | 157 // must be called on the UI thread. |
157 void NotifyOnUIThread(); | 158 void NotifyOnUIThread(); |
158 | 159 |
159 // Holds the current list of file systems returned to the client after | 160 // Holds the current list of file systems returned to the client after |
160 // StartFetching is called. | 161 // StartFetching is called. |
161 std::list<FileSystemInfo> file_system_info_; | 162 std::list<FileSystemInfo> file_system_info_; |
162 | 163 |
163 // Holds the callback passed in at the beginning of the StartFetching workflow | 164 // The callback passed in at the beginning of the StartFetching workflow so |
164 // so that it can be triggered via NotifyOnUIThread. | 165 // that it can be triggered via NotifyOnUIThread. |
165 scoped_ptr<Callback1<const std::list<FileSystemInfo>& >::Type > | 166 base::Callback<void(const std::list<FileSystemInfo>&)> completion_callback_; |
166 completion_callback_; | |
167 | 167 |
168 // Indicates whether or not we're currently fetching information: set to true | 168 // Indicates whether or not we're currently fetching information: set to true |
169 // when StartFetching is called on the UI thread, and reset to false when | 169 // when StartFetching is called on the UI thread, and reset to false when |
170 // NotifyOnUIThread triggers the success callback. | 170 // NotifyOnUIThread triggers the success callback. |
171 // This property only mutates on the UI thread. | 171 // This property only mutates on the UI thread. |
172 bool is_fetching_; | 172 bool is_fetching_; |
173 | 173 |
174 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataFileSystemHelper); | 174 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataFileSystemHelper); |
175 }; | 175 }; |
176 | 176 |
177 #endif // CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ | 177 #endif // CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ |
OLD | NEW |