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

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: Improved isolation of MockDownloadManager. 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_id.h"
24 #include "content/browser/download/download_state_info.h" 25 #include "content/browser/download/download_state_info.h"
25 #include "content/browser/download/interrupt_reasons.h" 26 #include "content/browser/download/interrupt_reasons.h"
26 27
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 virtual std::string GetReferrerCharset() const = 0; 243 virtual std::string GetReferrerCharset() const = 0;
240 virtual int64 GetTotalBytes() const = 0; 244 virtual int64 GetTotalBytes() const = 0;
241 virtual void SetTotalBytes(int64 total_bytes) = 0; 245 virtual void SetTotalBytes(int64 total_bytes) = 0;
242 virtual int64 GetReceivedBytes() const = 0; 246 virtual int64 GetReceivedBytes() const = 0;
243 virtual int32 GetId() const = 0; 247 virtual int32 GetId() const = 0;
244 virtual DownloadId GetGlobalId() const = 0; 248 virtual DownloadId GetGlobalId() const = 0;
245 virtual base::Time GetStartTime() const = 0; 249 virtual base::Time GetStartTime() const = 0;
246 virtual base::Time GetEndTime() const = 0; 250 virtual base::Time GetEndTime() const = 0;
247 virtual void SetDbHandle(int64 handle) = 0; 251 virtual void SetDbHandle(int64 handle) = 0;
248 virtual int64 GetDbHandle() const = 0; 252 virtual int64 GetDbHandle() const = 0;
249 virtual DownloadManager* GetDownloadManager() = 0;
250 virtual bool IsPaused() const = 0; 253 virtual bool IsPaused() const = 0;
251 virtual bool GetOpenWhenComplete() const = 0; 254 virtual bool GetOpenWhenComplete() const = 0;
252 virtual void SetOpenWhenComplete(bool open) = 0; 255 virtual void SetOpenWhenComplete(bool open) = 0;
253 virtual bool GetFileExternallyRemoved() const = 0; 256 virtual bool GetFileExternallyRemoved() const = 0;
254 virtual SafetyState GetSafetyState() const = 0; 257 virtual SafetyState GetSafetyState() const = 0;
255 // Why |safety_state_| is not SAFE. 258 // Why |safety_state_| is not SAFE.
256 virtual DownloadStateInfo::DangerType GetDangerType() const = 0; 259 virtual DownloadStateInfo::DangerType GetDangerType() const = 0;
257 virtual bool IsDangerous() const = 0; 260 virtual bool IsDangerous() const = 0;
258 virtual void MarkContentDangerous() = 0; 261 virtual void MarkContentDangerous() = 0;
259 virtual void MarkFileDangerous() = 0; 262 virtual void MarkFileDangerous() = 0;
260 virtual void MarkUrlDangerous() = 0; 263 virtual void MarkUrlDangerous() = 0;
261 264
262 virtual bool GetAutoOpened() = 0; 265 virtual bool GetAutoOpened() = 0;
263 virtual const FilePath& GetTargetName() const = 0; 266 virtual const FilePath& GetTargetName() const = 0;
264 virtual bool PromptUserForSaveLocation() const = 0; 267 virtual bool PromptUserForSaveLocation() const = 0;
265 virtual bool IsOtr() const = 0; 268 virtual bool IsOtr() const = 0;
266 virtual const FilePath& GetSuggestedPath() const = 0; 269 virtual const FilePath& GetSuggestedPath() const = 0;
267 virtual bool IsTemporary() const = 0; 270 virtual bool IsTemporary() const = 0;
268 virtual void SetOpened(bool opened) = 0; 271 virtual void SetOpened(bool opened) = 0;
269 virtual bool GetOpened() const = 0; 272 virtual bool GetOpened() const = 0;
270 273
271 virtual InterruptReason GetLastReason() const = 0; 274 virtual InterruptReason GetLastReason() const = 0;
272 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0; 275 virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const = 0;
273 virtual DownloadStateInfo GetStateInfo() const = 0; 276 virtual DownloadStateInfo GetStateInfo() const = 0;
277 virtual content::BrowserContext* BrowserContext() const = 0;
274 virtual TabContents* GetTabContents() const = 0; 278 virtual TabContents* GetTabContents() const = 0;
275 279
276 // Returns the final target file path for the download. 280 // Returns the final target file path for the download.
277 virtual FilePath GetTargetFilePath() const = 0; 281 virtual FilePath GetTargetFilePath() const = 0;
278 282
279 // Returns the file-name that should be reported to the user, which is 283 // Returns the file-name that should be reported to the user, which is
280 // target_name possibly with the uniquifier number. 284 // target_name possibly with the uniquifier number.
281 virtual FilePath GetFileNameToReportUser() const = 0; 285 virtual FilePath GetFileNameToReportUser() const = 0;
282 286
283 // Returns the user-verified target file path for the download. 287 // Returns the user-verified target file path for the download.
(...skipping 11 matching lines...) Expand all
295 // DownloadManager::FileSelectionCancelled() without doing some 299 // DownloadManager::FileSelectionCancelled() without doing some
296 // rewrites of the DownloadManager queues. 300 // rewrites of the DownloadManager queues.
297 virtual void OffThreadCancel(DownloadFileManager* file_manager) = 0; 301 virtual void OffThreadCancel(DownloadFileManager* file_manager) = 0;
298 302
299 virtual std::string DebugString(bool verbose) const = 0; 303 virtual std::string DebugString(bool verbose) const = 0;
300 304
301 virtual void MockDownloadOpenForTesting() = 0; 305 virtual void MockDownloadOpenForTesting() = 0;
302 }; 306 };
303 307
304 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 308 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698