| 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(content::WebContents* originating_web_contents, |
| 223 int request_id, |
| 224 const std::string& request_method, |
| 225 const Callback& orig_callback, |
| 226 bool allow); |
| 227 |
| 221 // Invoked on the UI thread. Schedules a call to NotifyCallback on the io | 228 // Invoked on the UI thread. Schedules a call to NotifyCallback on the io |
| 222 // thread. | 229 // thread. |
| 223 void ScheduleNotification(const Callback& callback, bool allow); | 230 void ScheduleNotification(const Callback& callback, bool allow); |
| 224 | 231 |
| 225 // Removes the specified TabDownloadState from the internal map and deletes | 232 // Removes the specified TabDownloadState from the internal map and deletes |
| 226 // it. This has the effect of resetting the status for the tab to | 233 // it. This has the effect of resetting the status for the tab to |
| 227 // ALLOW_ONE_DOWNLOAD. | 234 // ALLOW_ONE_DOWNLOAD. |
| 228 void Remove(TabDownloadState* state); | 235 void Remove(TabDownloadState* state); |
| 229 | 236 |
| 230 // Maps from tab to download state. The download state for a tab only exists | 237 // 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 | 238 // 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 | 239 // transitions from anything but ALLOW_ONE_DOWNLOAD back to ALLOW_ONE_DOWNLOAD |
| 233 // the TabDownloadState is removed and deleted (by way of Remove). | 240 // the TabDownloadState is removed and deleted (by way of Remove). |
| 234 typedef std::map<content::WebContents*, TabDownloadState*> StateMap; | 241 typedef std::map<content::WebContents*, TabDownloadState*> StateMap; |
| 235 StateMap state_map_; | 242 StateMap state_map_; |
| 236 | 243 |
| 244 // Weak ptr factory used when |CanDownload| asks the delegate asynchronously |
| 245 // about the download. |
| 246 base::WeakPtrFactory<DownloadRequestLimiter> factory_; |
| 247 |
| 237 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); | 248 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); |
| 238 }; | 249 }; |
| 239 | 250 |
| 240 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ | 251 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ |
| OLD | NEW |