Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: chrome/browser/download/download_request_limiter.h

Issue 13609002: fix a problem that android cannot download files with basic authentication (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // Returns the download status for a page. This does not change the state in 174 // Returns the download status for a page. This does not change the state in
175 // anyway. 175 // anyway.
176 DownloadStatus GetDownloadStatus(content::WebContents* tab); 176 DownloadStatus GetDownloadStatus(content::WebContents* tab);
177 177
178 // Updates the state of the page as necessary and notifies the callback. 178 // Updates the state of the page as necessary and notifies the callback.
179 // WARNING: both this call and the callback are invoked on the io thread. 179 // WARNING: both this call and the callback are invoked on the io thread.
180 void CanDownloadOnIOThread(int render_process_host_id, 180 void CanDownloadOnIOThread(int render_process_host_id,
181 int render_view_id, 181 int render_view_id,
182 int request_id, 182 int request_id,
183 const std::string& request_method, 183 const std::string& request_method,
184 bool has_auth,
184 const Callback& callback); 185 const Callback& callback);
185 186
186 private: 187 private:
187 FRIEND_TEST_ALL_PREFIXES(DownloadTest, DownloadResourceThrottleCancels); 188 FRIEND_TEST_ALL_PREFIXES(DownloadTest, DownloadResourceThrottleCancels);
188 friend class base::RefCountedThreadSafe<DownloadRequestLimiter>; 189 friend class base::RefCountedThreadSafe<DownloadRequestLimiter>;
189 friend class DownloadRequestLimiterTest; 190 friend class DownloadRequestLimiterTest;
190 friend class TabDownloadState; 191 friend class TabDownloadState;
191 192
192 ~DownloadRequestLimiter(); 193 ~DownloadRequestLimiter();
193 194
194 // Gets the download state for the specified controller. If the 195 // Gets the download state for the specified controller. If the
195 // TabDownloadState does not exist and |create| is true, one is created. 196 // TabDownloadState does not exist and |create| is true, one is created.
196 // See TabDownloadState's constructor description for details on the two 197 // See TabDownloadState's constructor description for details on the two
197 // controllers. 198 // controllers.
198 // 199 //
199 // The returned TabDownloadState is owned by the DownloadRequestLimiter and 200 // The returned TabDownloadState is owned by the DownloadRequestLimiter and
200 // deleted when no longer needed (the Remove method is invoked). 201 // deleted when no longer needed (the Remove method is invoked).
201 TabDownloadState* GetDownloadState( 202 TabDownloadState* GetDownloadState(
202 content::WebContents* web_contents, 203 content::WebContents* web_contents,
203 content::WebContents* originating_web_contents, 204 content::WebContents* originating_web_contents,
204 bool create); 205 bool create);
205 206
206 // CanDownloadOnIOThread invokes this on the UI thread. This determines the 207 // CanDownloadOnIOThread invokes this on the UI thread. This determines the
207 // tab and invokes CanDownloadImpl. 208 // tab and invokes CanDownloadImpl.
208 void CanDownload(int render_process_host_id, 209 void CanDownload(int render_process_host_id,
209 int render_view_id, 210 int render_view_id,
210 int request_id, 211 int request_id,
211 const std::string& request_method, 212 const std::string& request_method,
213 bool has_auth,
212 const Callback& callback); 214 const Callback& callback);
213 215
214 // Does the work of updating the download status on the UI thread and 216 // Does the work of updating the download status on the UI thread and
215 // potentially prompting the user. 217 // potentially prompting the user.
216 void CanDownloadImpl(content::WebContents* originating_contents, 218 void CanDownloadImpl(content::WebContents* originating_contents,
217 int request_id, 219 int request_id,
218 const std::string& request_method, 220 const std::string& request_method,
221 bool has_auth,
219 const Callback& callback); 222 const Callback& callback);
220 223
221 // Invoked on the UI thread. Schedules a call to NotifyCallback on the io 224 // Invoked on the UI thread. Schedules a call to NotifyCallback on the io
222 // thread. 225 // thread.
223 void ScheduleNotification(const Callback& callback, bool allow); 226 void ScheduleNotification(const Callback& callback, bool allow);
224 227
225 // Removes the specified TabDownloadState from the internal map and deletes 228 // Removes the specified TabDownloadState from the internal map and deletes
226 // it. This has the effect of resetting the status for the tab to 229 // it. This has the effect of resetting the status for the tab to
227 // ALLOW_ONE_DOWNLOAD. 230 // ALLOW_ONE_DOWNLOAD.
228 void Remove(TabDownloadState* state); 231 void Remove(TabDownloadState* state);
229 232
230 // Maps from tab to download state. The download state for a tab only exists 233 // 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 234 // 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 235 // transitions from anything but ALLOW_ONE_DOWNLOAD back to ALLOW_ONE_DOWNLOAD
233 // the TabDownloadState is removed and deleted (by way of Remove). 236 // the TabDownloadState is removed and deleted (by way of Remove).
234 typedef std::map<content::WebContents*, TabDownloadState*> StateMap; 237 typedef std::map<content::WebContents*, TabDownloadState*> StateMap;
235 StateMap state_map_; 238 StateMap state_map_;
236 239
237 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter); 240 DISALLOW_COPY_AND_ASSIGN(DownloadRequestLimiter);
238 }; 241 };
239 242
240 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_ 243 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_LIMITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698