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

Side by Side Diff: content/browser/download/save_package.h

Issue 2168403003: Avoid file IO on UI thread by moving more save-page-as stuff to the FILE thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment tweaks for base::nix::GetFileMimeType + two extra DCHECK_CURRENTLY_ON asserts in SavePackag… Created 4 years, 4 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
« no previous file with comments | « base/nix/mime_util_xdg.h ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // Look up SaveItem by save item id from in progress map. 296 // Look up SaveItem by save item id from in progress map.
297 SaveItem* LookupInProgressSaveItem(SaveItemId save_item_id); 297 SaveItem* LookupInProgressSaveItem(SaveItemId save_item_id);
298 298
299 // Remove SaveItem from in progress map and put it to saved map. 299 // Remove SaveItem from in progress map and put it to saved map.
300 void PutInProgressItemToSavedMap(SaveItem* save_item); 300 void PutInProgressItemToSavedMap(SaveItem* save_item);
301 301
302 // Retrieves the URL to be saved from the WebContents. 302 // Retrieves the URL to be saved from the WebContents.
303 static GURL GetUrlToBeSaved(WebContents* web_contents); 303 static GURL GetUrlToBeSaved(WebContents* web_contents);
304 304
305 static base::FilePath CreateDirectoryOnFileThread( 305 static base::FilePath CreateDirectoryOnFileThread(
306 const base::string16& title,
307 const GURL& page_url,
308 bool can_save_as_complete,
309 const std::string& mime_type,
306 const base::FilePath& website_save_dir, 310 const base::FilePath& website_save_dir,
307 const base::FilePath& download_save_dir, 311 const base::FilePath& download_save_dir,
308 const base::FilePath& suggested_filename,
309 bool skip_dir_check); 312 bool skip_dir_check);
310 void ContinueGetSaveInfo(bool can_save_as_complete, 313 void ContinueGetSaveInfo(bool can_save_as_complete,
311 const base::FilePath& suggested_path); 314 const base::FilePath& suggested_path);
312 void OnPathPicked( 315 void OnPathPicked(
313 const base::FilePath& final_name, 316 const base::FilePath& final_name,
314 SavePageType type, 317 SavePageType type,
315 const SavePackageDownloadCreatedCallback& cb); 318 const SavePackageDownloadCreatedCallback& cb);
316 319
317 // The number of in process SaveItems. 320 // The number of in process SaveItems.
318 int in_process_count() const { 321 int in_process_count() const {
319 return static_cast<int>(in_progress_items_.size()); 322 return static_cast<int>(in_progress_items_.size());
320 } 323 }
321 324
322 // The number of all SaveItems which have completed, including success items 325 // The number of all SaveItems which have completed, including success items
323 // and failed items. 326 // and failed items.
324 int completed_count() const { 327 int completed_count() const {
325 return static_cast<int>(saved_success_items_.size() + 328 return static_cast<int>(saved_success_items_.size() +
326 saved_failed_items_.size()); 329 saved_failed_items_.size());
327 } 330 }
328 331
329 // The current speed in files per second. This is used to update the 332 // The current speed in files per second. This is used to update the
330 // DownloadItem associated to this SavePackage. The files per second is 333 // DownloadItem associated to this SavePackage. The files per second is
331 // presented by the DownloadItem to the UI as bytes per second, which is 334 // presented by the DownloadItem to the UI as bytes per second, which is
332 // not correct but matches the way the total and received number of files is 335 // not correct but matches the way the total and received number of files is
333 // presented as the total and received bytes. 336 // presented as the total and received bytes.
334 int64_t CurrentSpeed() const; 337 int64_t CurrentSpeed() const;
335 338
336 // Helper function for preparing suggested name for the SaveAs Dialog. The 339 // Helper function for preparing suggested name for the SaveAs Dialog. The
337 // suggested name is determined by the web document's title. 340 // suggested name is determined by the web document's title.
338 base::FilePath GetSuggestedNameForSaveAs( 341 static base::FilePath GetSuggestedNameForSaveAs(
342 const base::string16& title,
343 const GURL& page_url,
339 bool can_save_as_complete, 344 bool can_save_as_complete,
340 const std::string& contents_mime_type); 345 const std::string& contents_mime_type);
341 346
342 // Ensures that the file name has a proper extension for HTML by adding ".htm" 347 // Ensures that the file name has a proper extension for HTML by adding ".htm"
343 // if necessary. 348 // if necessary.
344 static base::FilePath EnsureHtmlExtension(const base::FilePath& name); 349 static base::FilePath EnsureHtmlExtension(const base::FilePath& name);
345 350
346 // Ensures that the file name has a proper extension for supported formats 351 // Ensures that the file name has a proper extension for supported formats
347 // if necessary. 352 // if necessary.
348 static base::FilePath EnsureMimeExtension(const base::FilePath& name, 353 static base::FilePath EnsureMimeExtension(const base::FilePath& name,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 443
439 // Unique ID for this SavePackage. 444 // Unique ID for this SavePackage.
440 const SavePackageId unique_id_; 445 const SavePackageId unique_id_;
441 446
442 DISALLOW_COPY_AND_ASSIGN(SavePackage); 447 DISALLOW_COPY_AND_ASSIGN(SavePackage);
443 }; 448 };
444 449
445 } // namespace content 450 } // namespace content
446 451
447 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ 452 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
OLDNEW
« no previous file with comments | « base/nix/mime_util_xdg.h ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698