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

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

Issue 10704052: Download filename determination refactor (3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: BrowsingDataRemover calls CDMD directly Created 8 years, 5 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 CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 virtual void DownloadUrl( 69 virtual void DownloadUrl(
70 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE; 70 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE;
71 virtual void AddObserver(Observer* observer) OVERRIDE; 71 virtual void AddObserver(Observer* observer) OVERRIDE;
72 virtual void RemoveObserver(Observer* observer) OVERRIDE; 72 virtual void RemoveObserver(Observer* observer) OVERRIDE;
73 virtual void OnPersistentStoreQueryComplete( 73 virtual void OnPersistentStoreQueryComplete(
74 std::vector<content::DownloadPersistentStoreInfo>* entries) OVERRIDE; 74 std::vector<content::DownloadPersistentStoreInfo>* entries) OVERRIDE;
75 virtual void OnItemAddedToPersistentStore(int32 download_id, 75 virtual void OnItemAddedToPersistentStore(int32 download_id,
76 int64 db_handle) OVERRIDE; 76 int64 db_handle) OVERRIDE;
77 virtual int InProgressCount() const OVERRIDE; 77 virtual int InProgressCount() const OVERRIDE;
78 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; 78 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
79 virtual FilePath LastDownloadPath() OVERRIDE;
80 virtual net::BoundNetLog CreateDownloadItem( 79 virtual net::BoundNetLog CreateDownloadItem(
81 DownloadCreateInfo* info) OVERRIDE; 80 DownloadCreateInfo* info) OVERRIDE;
82 virtual content::DownloadItem* CreateSavePackageDownloadItem( 81 virtual content::DownloadItem* CreateSavePackageDownloadItem(
83 const FilePath& main_file_path, 82 const FilePath& main_file_path,
84 const GURL& page_url, 83 const GURL& page_url,
85 bool is_otr, 84 bool is_otr,
86 const std::string& mime_type, 85 const std::string& mime_type,
87 content::DownloadItem::Observer* observer) OVERRIDE; 86 content::DownloadItem::Observer* observer) OVERRIDE;
88 virtual void ClearLastDownloadPath() OVERRIDE;
89 virtual void FileSelected(const FilePath& path, int32 download_id) OVERRIDE;
90 virtual void FileSelectionCanceled(int32 download_id) OVERRIDE;
91 virtual void RestartDownload(int32 download_id) OVERRIDE;
92 virtual void CheckForHistoryFilesRemoval() OVERRIDE; 87 virtual void CheckForHistoryFilesRemoval() OVERRIDE;
93 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE; 88 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE;
94 virtual content::DownloadItem* GetDownload(int id) OVERRIDE; 89 virtual content::DownloadItem* GetDownload(int id) OVERRIDE;
95 virtual void SavePageDownloadFinished( 90 virtual void SavePageDownloadFinished(
96 content::DownloadItem* download) OVERRIDE; 91 content::DownloadItem* download) OVERRIDE;
97 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE; 92 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE;
98 virtual bool GenerateFileHash() OVERRIDE; 93 virtual bool GenerateFileHash() OVERRIDE;
99 94
100 // Overridden from DownloadItemImpl::Delegate 95 // Overridden from DownloadItemImpl::Delegate
101 // (Note that |GetBrowserContext| are present in both interfaces.) 96 // (Note that |GetBrowserContext| are present in both interfaces.)
97 virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE;
102 virtual bool ShouldOpenDownload(content::DownloadItem* item) OVERRIDE; 98 virtual bool ShouldOpenDownload(content::DownloadItem* item) OVERRIDE;
103 virtual bool ShouldOpenFileBasedOnExtension( 99 virtual bool ShouldOpenFileBasedOnExtension(
104 const FilePath& path) OVERRIDE; 100 const FilePath& path) OVERRIDE;
105 virtual void CheckForFileRemoval( 101 virtual void CheckForFileRemoval(
106 content::DownloadItem* download_item) OVERRIDE; 102 content::DownloadItem* download_item) OVERRIDE;
107 virtual void MaybeCompleteDownload( 103 virtual void MaybeCompleteDownload(
108 content::DownloadItem* download) OVERRIDE; 104 content::DownloadItem* download) OVERRIDE;
109 virtual void DownloadStopped( 105 virtual void DownloadStopped(
110 content::DownloadItem* download) OVERRIDE; 106 content::DownloadItem* download) OVERRIDE;
111 virtual void DownloadCompleted( 107 virtual void DownloadCompleted(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 content::DownloadId GetNextId(); 143 content::DownloadId GetNextId();
148 144
149 // Called on the FILE thread to check the existence of a downloaded file. 145 // Called on the FILE thread to check the existence of a downloaded file.
150 void CheckForFileRemovalOnFileThread(int32 download_id, const FilePath& path); 146 void CheckForFileRemovalOnFileThread(int32 download_id, const FilePath& path);
151 147
152 // Called on the UI thread if the FILE thread detects the removal of 148 // Called on the UI thread if the FILE thread detects the removal of
153 // the downloaded file. The UI thread updates the state of the file 149 // the downloaded file. The UI thread updates the state of the file
154 // and then notifies this update to the file's observer. 150 // and then notifies this update to the file's observer.
155 void OnFileRemovalDetected(int32 download_id); 151 void OnFileRemovalDetected(int32 download_id);
156 152
157 // Called back after a target path for the file to be downloaded to has been
158 // determined, either automatically based on the suggested file name, or by
159 // the user in a Save As dialog box.
160 void OnTargetPathAvailable(content::DownloadItem* download);
161
162 // Retrieves the download from the |download_id|. 153 // Retrieves the download from the |download_id|.
163 // Returns NULL if the download is not active. 154 // Returns NULL if the download is not active.
164 content::DownloadItem* GetActiveDownload(int32 download_id); 155 content::DownloadItem* GetActiveDownload(int32 download_id);
165 156
166 // Removes |download| from the active and in progress maps. 157 // Removes |download| from the active and in progress maps.
167 // Called when the download is cancelled or has an error. 158 // Called when the download is cancelled or has an error.
168 // Does nothing if the download is not in the history DB. 159 // Does nothing if the download is not in the history DB.
169 void RemoveFromActiveList(content::DownloadItem* download); 160 void RemoveFromActiveList(content::DownloadItem* download);
170 161
171 // Inform observers that the model has changed. 162 // Inform observers that the model has changed.
172 void NotifyModelChanged(); 163 void NotifyModelChanged();
173 164
174 // Debugging routine to confirm relationship between below 165 // Debugging routine to confirm relationship between below
175 // containers; no-op if NDEBUG. 166 // containers; no-op if NDEBUG.
176 void AssertContainersConsistent() const; 167 void AssertContainersConsistent() const;
177 168
178 // Add a DownloadItem to history_downloads_. 169 // Add a DownloadItem to history_downloads_.
179 void AddDownloadItemToHistory(content::DownloadItem* item, int64 db_handle); 170 void AddDownloadItemToHistory(content::DownloadItem* item, int64 db_handle);
180 171
181 // Remove from internal maps. 172 // Remove from internal maps.
182 int RemoveDownloadItems(const DownloadVector& pending_deletes); 173 int RemoveDownloadItems(const DownloadVector& pending_deletes);
183 174
184 // Called in response to our request to the DownloadFileManager to 175 // Called in response to our request to the DownloadFileManager to
185 // create a DownloadFile. A |reason| of 176 // create a DownloadFile. A |reason| of
186 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. 177 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success.
187 void OnDownloadFileCreated( 178 void OnDownloadFileCreated(
188 int32 download_id, content::DownloadInterruptReason reason); 179 int32 download_id, content::DownloadInterruptReason reason);
189 180
181 void OnDownloadTargetDetermined(
182 int32 download_id,
183 const FilePath& target_path,
184 content::DownloadItem::TargetDisposition disposition,
185 content::DownloadDangerType danger_type,
186 const FilePath& intermediate_path);
187
190 // Called when a download entry is committed to the persistent store. 188 // Called when a download entry is committed to the persistent store.
191 void OnDownloadItemAddedToPersistentStore(int32 download_id, int64 db_handle); 189 void OnDownloadItemAddedToPersistentStore(int32 download_id, int64 db_handle);
192 190
193 // Called when Save Page As entry is committed to the persistent store. 191 // Called when Save Page As entry is committed to the persistent store.
194 void OnSavePageItemAddedToPersistentStore(int32 download_id, int64 db_handle); 192 void OnSavePageItemAddedToPersistentStore(int32 download_id, int64 db_handle);
195 193
196 // Factory for creation of downloads items. 194 // Factory for creation of downloads items.
197 scoped_ptr<content::DownloadItemFactory> factory_; 195 scoped_ptr<content::DownloadItemFactory> factory_;
198 196
199 // |downloads_| is the owning set for all downloads known to the 197 // |downloads_| is the owning set for all downloads known to the
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 232
235 // Observers that want to be notified of changes to the set of downloads. 233 // Observers that want to be notified of changes to the set of downloads.
236 ObserverList<Observer> observers_; 234 ObserverList<Observer> observers_;
237 235
238 // The current active browser context. 236 // The current active browser context.
239 content::BrowserContext* browser_context_; 237 content::BrowserContext* browser_context_;
240 238
241 // Non-owning pointer for handling file writing on the download_thread_. 239 // Non-owning pointer for handling file writing on the download_thread_.
242 DownloadFileManager* file_manager_; 240 DownloadFileManager* file_manager_;
243 241
244 // The user's last choice for download directory. This is only used when the
245 // user wants us to prompt for a save location for each download.
246 FilePath last_download_path_;
247
248 // Allows an embedder to control behavior. Guaranteed to outlive this object. 242 // Allows an embedder to control behavior. Guaranteed to outlive this object.
249 content::DownloadManagerDelegate* delegate_; 243 content::DownloadManagerDelegate* delegate_;
250 244
251 net::NetLog* net_log_; 245 net::NetLog* net_log_;
252 246
253 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); 247 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl);
254 }; 248 };
255 249
256 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ 250 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698