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_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 const std::string& request_method, | 211 const std::string& request_method, |
212 const Callback& callback); | 212 const Callback& callback); |
213 | 213 |
214 // Does the work of updating the download status on the UI thread and | 214 // Does the work of updating the download status on the UI thread and |
215 // potentially prompting the user. | 215 // potentially prompting the user. |
216 void CanDownloadImpl(content::WebContents* originating_contents, | 216 void CanDownloadImpl(content::WebContents* originating_contents, |
217 int request_id, | 217 int request_id, |
218 const std::string& request_method, | 218 const std::string& request_method, |
219 const Callback& callback); | 219 const Callback& callback); |
220 | 220 |
| 221 // Invoked when decision to download has been made. |
| 222 void OnCanDownloadDecided(int render_process_host_id, |
| 223 int render_view_id, |
| 224 int request_id, |
| 225 const std::string& request_method, |
| 226 const Callback& orig_callback, |
| 227 bool allow); |
| 228 |
221 // Invoked on the UI thread. Schedules a call to NotifyCallback on the io | 229 // Invoked on the UI thread. Schedules a call to NotifyCallback on the io |
222 // thread. | 230 // thread. |
223 void ScheduleNotification(const Callback& callback, bool allow); | 231 void ScheduleNotification(const Callback& callback, bool allow); |
224 | 232 |
225 // Removes the specified TabDownloadState from the internal map and deletes | 233 // Removes the specified TabDownloadState from the internal map and deletes |
226 // it. This has the effect of resetting the status for the tab to | 234 // it. This has the effect of resetting the status for the tab to |
227 // ALLOW_ONE_DOWNLOAD. | 235 // ALLOW_ONE_DOWNLOAD. |
228 void Remove(TabDownloadState* state); | 236 void Remove(TabDownloadState* state); |
229 | 237 |
230 // Maps from tab to download state. The download state for a tab only exists | 238 // Maps from tab to download state. The download state for a tab only exists |
231 // if the state is other than ALLOW_ONE_DOWNLOAD. Similarly once the state | 239 // if the state is other than ALLOW_ONE_DOWNLOAD. Similarly once the state |
232 // transitions from anything but ALLOW_ONE_DOWNLOAD back to ALLOW_ONE_DOWNLOAD | 240 // transitions from anything but ALLOW_ONE_DOWNLOAD back to ALLOW_ONE_DOWNLOAD |
233 // the TabDownloadState is removed and deleted (by way of Remove). | 241 // the TabDownloadState is removed and deleted (by way of Remove). |
234 typedef std::map<content::WebContents*, TabDownloadState*> StateMap; | 242 typedef std::map<content::WebContents*, TabDownloadState*> StateMap; |
235 StateMap state_map_; | 243 StateMap state_map_; |
236 | 244 |
| 245 // Weak ptr factory used when |CanDownload| asks the delegate asynchronously |
| 246 // about the download. |
| 247 base::WeakPtrFactory<DownloadRequestLimiter> factory_; |
| 248 |
237 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); | 249 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); |
238 }; | 250 }; |
239 | 251 |
240 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ | 252 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ |
OLD | NEW |