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

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

Issue 8697006: DownloadManager intereface refactoring to allow cleaner DownloadItem unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added CONTENT_EXPORT to delegate. Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Each download is represented by a DownloadItem, and all DownloadItems 5 // Each download is represented by a DownloadItem, and all DownloadItems
6 // are owned by the DownloadManager which maintains a global list of all 6 // are owned by the DownloadManager which maintains a global list of all
7 // downloads. DownloadItems are created when a user initiates a download, 7 // downloads. DownloadItems are created when a user initiates a download,
8 // and exist for the duration of the browser life time. 8 // and exist for the duration of the browser life time.
9 // 9 //
10 // Download observers: 10 // Download observers:
11 // DownloadItem::Observer: 11 // DownloadItem::Observer:
12 // - allows observers to receive notifications about one download from start 12 // - allows observers to receive notifications about one download from start
13 // to completion 13 // to completion
14 // Use AddObserver() / RemoveObserver() on the appropriate download object to 14 // Use AddObserver() / RemoveObserver() on the appropriate download object to
15 // receive state updates. 15 // receive state updates.
16 16
17 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 17 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
18 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 18 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
19 #pragma once 19 #pragma once
20 20
21 #include <string> 21 #include <string>
22 22
23 #include "base/string16.h" 23 #include "base/string16.h"
24 #include "content/browser/download/download_state_info.h" 24 #include "content/browser/download/download_state_info.h"
25 #include "content/browser/download/interrupt_reasons.h" 25 #include "content/browser/download/interrupt_reasons.h"
26 26
27 class DownloadId;
27 class DownloadFileManager; 28 class DownloadFileManager;
28 class DownloadId;
29 class DownloadManager; 29 class DownloadManager;
30 class FilePath; 30 class FilePath;
31 class GURL; 31 class GURL;
32 class TabContents; 32 class TabContents;
33 struct DownloadCreateInfo; 33 struct DownloadCreateInfo;
34 struct DownloadPersistentStoreInfo; 34 struct DownloadPersistentStoreInfo;
35 namespace base { 35 namespace base {
36 class Time; 36 class Time;
37 class TimeDelta; 37 class TimeDelta;
38 } 38 }
39 39
40 namespace content {
41 class BrowserContext;
42 }
43
40 // One DownloadItem per download. This is the model class that stores all the 44 // One DownloadItem per download. This is the model class that stores all the
41 // state for a download. Multiple views, such as a tab's download shelf and the 45 // state for a download. Multiple views, such as a tab's download shelf and the
42 // Destination tab's download view, may refer to a given DownloadItem. 46 // Destination tab's download view, may refer to a given DownloadItem.
43 // 47 //
44 // This is intended to be used only on the UI thread. 48 // This is intended to be used only on the UI thread.
45 class CONTENT_EXPORT DownloadItem { 49 class CONTENT_EXPORT DownloadItem {
46 public: 50 public:
47 enum DownloadState { 51 enum DownloadState {
48 // Download is actively progressing. 52 // Download is actively progressing.
49 IN_PROGRESS = 0, 53 IN_PROGRESS = 0,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // Called by the delegate after it delayed opening the download in 150 // Called by the delegate after it delayed opening the download in
147 // DownloadManagerDelegate::ShouldOpenDownload. 151 // DownloadManagerDelegate::ShouldOpenDownload.
148 virtual void DelayedDownloadOpened() = 0; 152 virtual void DelayedDownloadOpened() = 0;
149 153
150 // Called when all data has been saved. Only has display effects. 154 // Called when all data has been saved. Only has display effects.
151 virtual void OnAllDataSaved(int64 size, const std::string& final_hash) = 0; 155 virtual void OnAllDataSaved(int64 size, const std::string& final_hash) = 0;
152 156
153 // Called when the downloaded file is removed. 157 // Called when the downloaded file is removed.
154 virtual void OnDownloadedFileRemoved() = 0; 158 virtual void OnDownloadedFileRemoved() = 0;
155 159
160 // If all pre-requisites have been met, complete download processing, i.e.
161 // do internal cleanup, file rename, and potentially auto-open.
162 // (Dangerous downloads still may block on user acceptance after this
163 // point.)
164 virtual void MaybeCompleteDownload() = 0;
165
156 // Download operation had an error. 166 // Download operation had an error.
157 // |size| is the amount of data received at interruption. 167 // |size| is the amount of data received at interruption.
158 // |reason| is the download interrupt reason code that the operation received. 168 // |reason| is the download interrupt reason code that the operation received.
159 virtual void Interrupted(int64 size, InterruptReason reason) = 0; 169 virtual void Interrupted(int64 size, InterruptReason reason) = 0;
160 170
161 // Deletes the file from disk and removes the download from the views and 171 // Deletes the file from disk and removes the download from the views and
162 // history. |user| should be true if this is the result of the user clicking 172 // history. |user| should be true if this is the result of the user clicking
163 // the discard button, and false if it is being deleted for other reasons like 173 // the discard button, and false if it is being deleted for other reasons like
164 // browser shutdown. 174 // browser shutdown.
165 virtual void Delete(DeleteReason reason) = 0; 175 virtual void Delete(DeleteReason reason) = 0;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 virtual std::string GetRemoteAddress() const = 0; 251 virtual std::string GetRemoteAddress() const = 0;
242 virtual int64 GetTotalBytes() const = 0; 252 virtual int64 GetTotalBytes() const = 0;
243 virtual void SetTotalBytes(int64 total_bytes) = 0; 253 virtual void SetTotalBytes(int64 total_bytes) = 0;
244 virtual int64 GetReceivedBytes() const = 0; 254 virtual int64 GetReceivedBytes() const = 0;
245 virtual int32 GetId() const = 0; 255 virtual int32 GetId() const = 0;
246 virtual DownloadId GetGlobalId() const = 0; 256 virtual DownloadId GetGlobalId() const = 0;
247 virtual base::Time GetStartTime() const = 0; 257 virtual base::Time GetStartTime() const = 0;
248 virtual base::Time GetEndTime() const = 0; 258 virtual base::Time GetEndTime() const = 0;
249 virtual void SetDbHandle(int64 handle) = 0; 259 virtual void SetDbHandle(int64 handle) = 0;
250 virtual int64 GetDbHandle() const = 0; 260 virtual int64 GetDbHandle() const = 0;
251 virtual DownloadManager* GetDownloadManager() = 0;
252 virtual bool IsPaused() const = 0; 261 virtual bool IsPaused() const = 0;
253 virtual bool GetOpenWhenComplete() const = 0; 262 virtual bool GetOpenWhenComplete() const = 0;
254 virtual void SetOpenWhenComplete(bool open) = 0; 263 virtual void SetOpenWhenComplete(bool open) = 0;
255 virtual bool GetFileExternallyRemoved() const = 0; 264 virtual bool GetFileExternallyRemoved() const = 0;
256 virtual SafetyState GetSafetyState() const = 0; 265 virtual SafetyState GetSafetyState() const = 0;
257 // Why |safety_state_| is not SAFE. 266 // Why |safety_state_| is not SAFE.
258 virtual DownloadStateInfo::DangerType GetDangerType() const = 0; 267 virtual DownloadStateInfo::DangerType GetDangerType() const = 0;
259 virtual bool IsDangerous() const = 0; 268 virtual bool IsDangerous() const = 0;
260 virtual void MarkContentDangerous() = 0; 269 virtual void MarkContentDangerous() = 0;
261 virtual void MarkFileDangerous() = 0; 270 virtual void MarkFileDangerous() = 0;
262 virtual void MarkUrlDangerous() = 0; 271 virtual void MarkUrlDangerous() = 0;
263 272
264 virtual bool GetAutoOpened() = 0; 273 virtual bool GetAutoOpened() = 0;
265 virtual const FilePath& GetTargetName() const = 0; 274 virtual const FilePath& GetTargetName() const = 0;
266 virtual bool PromptUserForSaveLocation() const = 0; 275 virtual bool PromptUserForSaveLocation() const = 0;
267 virtual bool IsOtr() const = 0; 276 virtual bool IsOtr() const = 0;
268 virtual const FilePath& GetSuggestedPath() const = 0; 277 virtual const FilePath& GetSuggestedPath() const = 0;
269 virtual bool IsTemporary() const = 0; 278 virtual bool IsTemporary() const = 0;
270 virtual void SetOpened(bool opened) = 0; 279 virtual void SetOpened(bool opened) = 0;
271 virtual bool GetOpened() const = 0; 280 virtual bool GetOpened() const = 0;
272 281
273 virtual InterruptReason GetLastReason() const = 0; 282 virtual InterruptReason GetLastReason() const = 0;
274 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; 283 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0;
275 virtual DownloadStateInfo GetStateInfo() const = 0; 284 virtual DownloadStateInfo GetStateInfo() const = 0;
285 virtual content::BrowserContext* BrowserContext() const = 0;
276 virtual TabContents* GetTabContents() const = 0; 286 virtual TabContents* GetTabContents() const = 0;
277 287
278 // Returns the final target file path for the download. 288 // Returns the final target file path for the download.
279 virtual FilePath GetTargetFilePath() const = 0; 289 virtual FilePath GetTargetFilePath() const = 0;
280 290
281 // Returns the file-name that should be reported to the user, which is 291 // Returns the file-name that should be reported to the user, which is
282 // target_name possibly with the uniquifier number. 292 // target_name possibly with the uniquifier number.
283 virtual FilePath GetFileNameToReportUser() const = 0; 293 virtual FilePath GetFileNameToReportUser() const = 0;
284 294
285 // Returns the user-verified target file path for the download. 295 // Returns the user-verified target file path for the download.
(...skipping 11 matching lines...) Expand all
297 // DownloadManager::FileSelectionCancelled() without doing some 307 // DownloadManager::FileSelectionCancelled() without doing some
298 // rewrites of the DownloadManager queues. 308 // rewrites of the DownloadManager queues.
299 virtual void OffThreadCancel(DownloadFileManager* file_manager) = 0; 309 virtual void OffThreadCancel(DownloadFileManager* file_manager) = 0;
300 310
301 virtual std::string DebugString(bool verbose) const = 0; 311 virtual std::string DebugString(bool verbose) const = 0;
302 312
303 virtual void MockDownloadOpenForTesting() = 0; 313 virtual void MockDownloadOpenForTesting() = 0;
304 }; 314 };
305 315
306 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 316 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_shelf_context_menu.cc ('k') | content/browser/download/download_item_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698