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

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

Powered by Google App Engine
This is Rietveld 408576698