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