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

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

Issue 219017: Create the download folder if it doesn't exist. That is, the actual download ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix unit tests Created 11 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/download/save_file_manager.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Objects that handle file operations for saving files, on the file thread. 5 // Objects that handle file operations for saving files, on the file thread.
6 // 6 //
7 // The SaveFileManager owns a set of SaveFile objects, each of which connects 7 // The SaveFileManager owns a set of SaveFile objects, each of which connects
8 // with a SaveItem object which belongs to one SavePackage and runs on the file 8 // with a SaveItem object which belongs to one SavePackage and runs on the file
9 // thread for saving data in order to avoid disk activity on either network IO 9 // thread for saving data in order to avoid disk activity on either network IO
10 // thread or the UI thread. It coordinates the notifications from the network 10 // thread or the UI thread. It coordinates the notifications from the network
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // 51 //
52 // The SaveFileManager tracks saving requests, mapping from a save ID 52 // The SaveFileManager tracks saving requests, mapping from a save ID
53 // (unique integer created in the IO thread) to the SavePackage for the 53 // (unique integer created in the IO thread) to the SavePackage for the
54 // tab where the saving job was initiated. In the event of a tab closure 54 // tab where the saving job was initiated. In the event of a tab closure
55 // during saving, the SavePackage will notice the SaveFileManage to 55 // during saving, the SavePackage will notice the SaveFileManage to
56 // cancel all SaveFile job. 56 // cancel all SaveFile job.
57 57
58 #ifndef CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__ 58 #ifndef CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__
59 #define CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__ 59 #define CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__
60 60
61 #include <string>
62
61 #include "base/basictypes.h" 63 #include "base/basictypes.h"
62 #include "base/file_path.h" 64 #include "base/file_path.h"
63 #include "base/hash_tables.h" 65 #include "base/hash_tables.h"
64 #include "base/ref_counted.h" 66 #include "base/ref_counted.h"
65 #include "chrome/browser/download/save_types.h" 67 #include "chrome/browser/download/save_types.h"
66 68
67 namespace net { 69 namespace net {
68 class IOBuffer; 70 class IOBuffer;
69 } 71 }
70 class GURL; 72 class GURL;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 void RemoveSaveFile(int save_id, const GURL& save_url, 117 void RemoveSaveFile(int save_id, const GURL& save_url,
116 SavePackage* package); 118 SavePackage* package);
117 119
118 #if !defined(OS_MACOSX) 120 #if !defined(OS_MACOSX)
119 // Handler for shell operations sent from the UI to the file thread. Mac OS X 121 // Handler for shell operations sent from the UI to the file thread. Mac OS X
120 // requires opening downloads on the UI thread, so it does not use this 122 // requires opening downloads on the UI thread, so it does not use this
121 // method. 123 // method.
122 void OnShowSavedFileInShell(const FilePath full_path); 124 void OnShowSavedFileInShell(const FilePath full_path);
123 #endif 125 #endif
124 126
127 // Helper to create the download directory.
128 void CreateDownloadDirectory(FilePath save_dir,
129 SavePackage* save_package);
125 // Helper function for deleting specified file. 130 // Helper function for deleting specified file.
126 void DeleteDirectoryOrFile(const FilePath& full_path, bool is_dir); 131 void DeleteDirectoryOrFile(const FilePath& full_path, bool is_dir);
127 132
128 // For posting notifications from the UI and file threads. 133 // For posting notifications from the UI and file threads.
129 MessageLoop* ui_loop() const { return ui_loop_; } 134 MessageLoop* ui_loop() const { return ui_loop_; }
130 MessageLoop* file_loop() const { return file_loop_; } 135 MessageLoop* file_loop() const { return file_loop_; }
131 136
132 // Runs on file thread to save a file by copying from file system when 137 // Runs on file thread to save a file by copying from file system when
133 // original url is using file scheme. 138 // original url is using file scheme.
134 void SaveLocalFile(const GURL& original_file_url, 139 void SaveLocalFile(const GURL& original_file_url,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // as starting requests. For tracking those starting requests, we need to 260 // as starting requests. For tracking those starting requests, we need to
256 // have some data structure. 261 // have some data structure.
257 // First we use a hashmap to map the request URL to SavePackage, then we 262 // First we use a hashmap to map the request URL to SavePackage, then we
258 // use a hashmap to map the tab id (we actually use render_process_id) to the 263 // use a hashmap to map the tab id (we actually use render_process_id) to the
259 // hashmap since it is possible to save same URL in different tab at 264 // hashmap since it is possible to save same URL in different tab at
260 // same time. 265 // same time.
261 typedef base::hash_map<std::string, SavePackage*> StartingRequestsMap; 266 typedef base::hash_map<std::string, SavePackage*> StartingRequestsMap;
262 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap; 267 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap;
263 TabToStartingRequestsMap tab_starting_requests_; 268 TabToStartingRequestsMap tab_starting_requests_;
264 269
265 DISALLOW_EVIL_CONSTRUCTORS(SaveFileManager); 270 DISALLOW_COPY_AND_ASSIGN(SaveFileManager);
266 }; 271 };
267 272
268 #endif // CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__ 273 #endif // CHROME_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H__
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/save_file_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698