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

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

Issue 8351052: Created a DownloadManager interface, for use in unit tests.. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved comment. Created 9 years, 1 month 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 #ifndef CONTENT_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_
6 #define CONTENT_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "content/browser/download/download_manager.h" 9 #include "content/browser/download/download_manager.h"
10 #include "content/browser/download/download_id.h"
10 11
11 class DownloadStatusUpdater; 12 class DownloadStatusUpdater;
12 class DownloadItem; 13 class DownloadItem;
13 14
14 class MockDownloadManager : public DownloadManager { 15 class MockDownloadManager : public DownloadManager {
15 public: 16 public:
16 explicit MockDownloadManager(content::DownloadManagerDelegate* delegate, 17 explicit MockDownloadManager(content::DownloadManagerDelegate* delegate,
17 DownloadIdFactory* id_factory, 18 DownloadIdFactory* id_factory,
18 DownloadStatusUpdater* updater) 19 DownloadStatusUpdater* updater);
19 : DownloadManager(delegate, id_factory, updater) { 20 virtual ~MockDownloadManager();
20 }
21 21
22 // Override some functions. 22 // DownloadManager:
23 virtual void UpdateHistoryForDownload(DownloadItem*) { } 23 virtual void Shutdown() OVERRIDE;
24 virtual void GetTemporaryDownloads(const FilePath& dir_path,
25 DownloadVector* result) OVERRIDE;
26 virtual void GetAllDownloads(const FilePath& dir_path,
27 DownloadVector* result) OVERRIDE;
28 virtual void SearchDownloads(const string16& query,
29 DownloadVector* result) OVERRIDE;
30 virtual bool Init(content::BrowserContext* browser_context) OVERRIDE;
31 virtual void StartDownload(int32 id) OVERRIDE;
32 virtual void UpdateDownload(int32 download_id, int64 size) OVERRIDE;
33 virtual void OnResponseCompleted(int32 download_id, int64 size,
34 const std::string& hash) OVERRIDE;
35 virtual void CancelDownload(int32 download_id) OVERRIDE;
36 virtual void OnDownloadInterrupted(int32 download_id, int64 size,
37 InterruptReason reason) OVERRIDE;
38 virtual void DownloadCancelledInternal(DownloadItem* download) OVERRIDE;
39 virtual void RemoveDownload(int64 download_handle) OVERRIDE;
40 virtual bool IsDownloadReadyForCompletion(DownloadItem* download) OVERRIDE;
41 virtual void MaybeCompleteDownload(DownloadItem* download) OVERRIDE;
42 virtual void OnDownloadRenamedToFinalName(int download_id,
43 const FilePath& full_path,
44 int uniquifier) OVERRIDE;
45 virtual int RemoveDownloadsBetween(const base::Time remove_begin,
46 const base::Time remove_end) OVERRIDE;
47 virtual int RemoveDownloads(const base::Time remove_begin) OVERRIDE;
48 virtual int RemoveAllDownloads() OVERRIDE;
49 virtual void DownloadCompleted(int32 download_id) OVERRIDE;
50 virtual void DownloadUrl(const GURL& url,
51 const GURL& referrer,
52 const std::string& referrer_encoding,
53 TabContents* tab_contents) OVERRIDE;
54 virtual void DownloadUrlToFile(const GURL& url,
55 const GURL& referrer,
56 const std::string& referrer_encoding,
57 const DownloadSaveInfo& save_info,
58 TabContents* tab_contents) OVERRIDE;
59 virtual void AddObserver(Observer* observer) OVERRIDE;
60 virtual void RemoveObserver(Observer* observer) OVERRIDE;
61 virtual void OnPersistentStoreQueryComplete(
62 std::vector<DownloadPersistentStoreInfo>* entries) OVERRIDE;
63 virtual void OnItemAddedToPersistentStore(int32 download_id,
64 int64 db_handle) OVERRIDE;
65 virtual void ShowDownloadInBrowser(DownloadItem* download) OVERRIDE;
66 virtual int InProgressCount() const OVERRIDE;
67 virtual content::BrowserContext* BrowserContext() OVERRIDE;
68 virtual FilePath LastDownloadPath() OVERRIDE;
69 virtual void CreateDownloadItem(
70 DownloadCreateInfo* info,
71 const DownloadRequestHandle& request_handle) OVERRIDE;
72 virtual void ClearLastDownloadPath() OVERRIDE;
73 virtual void FileSelected(const FilePath& path, void* params) OVERRIDE;
74 virtual void FileSelectionCanceled(void* params) OVERRIDE;
75 virtual void RestartDownload(int32 download_id) OVERRIDE;
76 virtual void MarkDownloadOpened(DownloadItem* download) OVERRIDE;
77 virtual void CheckForHistoryFilesRemoval() OVERRIDE;
78 virtual void CheckForFileRemoval(DownloadItem* download_item) OVERRIDE;
79 virtual void AssertQueueStateConsistent(DownloadItem* download) OVERRIDE;
80 virtual DownloadItem* GetDownloadItem(int id) OVERRIDE;
81 virtual void SavePageDownloadStarted(DownloadItem* download) OVERRIDE;
82 virtual void SavePageDownloadFinished(DownloadItem* download) OVERRIDE;
83 virtual DownloadItem* GetActiveDownloadItem(int id) OVERRIDE;
84 virtual content::DownloadManagerDelegate* delegate() const OVERRIDE;
85 virtual void SetDownloadManagerDelegate(
86 content::DownloadManagerDelegate* delegate) OVERRIDE;
87 virtual DownloadId GetNextId() OVERRIDE;
88 virtual void ContinueDownloadWithPath(DownloadItem* download,
89 const FilePath& chosen_file) OVERRIDE;
90 virtual DownloadItem* GetActiveDownload(int32 download_id) OVERRIDE;
91 virtual void SetFileManager(DownloadFileManager* file_manager) OVERRIDE;
92
93 private:
94 content::DownloadManagerDelegate* delegate_;
95 DownloadIdFactory* id_factory_;
96 DownloadStatusUpdater* updater_;
97 DownloadFileManager* file_manager_;
98 std::map<int32, DownloadItem*> item_map_;
24 }; 99 };
25 100
26 #endif // CONTENT_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ 101 #endif // CONTENT_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698