| Index: content/browser/download/mock_download_manager.cc
|
| diff --git a/content/browser/download/mock_download_manager.cc b/content/browser/download/mock_download_manager.cc
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..5b3f70a5b7b27b5fc5416e1d45c58a901a17e1e7
|
| --- /dev/null
|
| +++ b/content/browser/download/mock_download_manager.cc
|
| @@ -0,0 +1,265 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/browser/download/mock_download_manager.h"
|
| +
|
| +MockDownloadManager::MockDownloadManager(
|
| + content::DownloadManagerDelegate* delegate,
|
| + DownloadIdFactory* id_factory,
|
| + DownloadStatusUpdater* updater)
|
| + : delegate_(delegate), id_factory_(id_factory), updater_(updater) {
|
| +}
|
| +
|
| +// Shutdown the download manager. Must be called before destruction.
|
| +void MockDownloadManager::Shutdown() {
|
| +}
|
| +
|
| +// Return all temporary downloads that reside in the specified directory.
|
| +void MockDownloadManager::GetTemporaryDownloads(const FilePath& dir_path,
|
| + DownloadVector* result) {
|
| +}
|
| +
|
| +// Return all non-temporary downloads in the specified directory that are
|
| +// are in progress or have completed.
|
| +void MockDownloadManager::GetAllDownloads(const FilePath& dir_path,
|
| + DownloadVector* result) {
|
| +}
|
| +
|
| +// Returns all non-temporary downloads matching |query|. Empty query matches
|
| +// everything.
|
| +void MockDownloadManager::SearchDownloads(const string16& query,
|
| + DownloadVector* result) {
|
| +}
|
| +
|
| +// Returns true if initialized properly.
|
| +bool MockDownloadManager::Init(content::BrowserContext* browser_context) {
|
| + return true;
|
| +}
|
| +
|
| +// Notifications sent from the download thread to the UI thread
|
| +void MockDownloadManager::StartDownload(int32 id) {
|
| +}
|
| +void MockDownloadManager::UpdateDownload(int32 download_id, int64 size) {
|
| +}
|
| +
|
| +// |download_id| is the ID of the download.
|
| +// |size| is the number of bytes that have been downloaded.
|
| +// |hash| is sha256 hash for the downloaded file. It is empty when the hash
|
| +// is not available.
|
| +void MockDownloadManager::OnResponseCompleted(int32 download_id, int64 size,
|
| + const std::string& hash) {
|
| +}
|
| +
|
| +// Offthread target for cancelling a particular download. Will be a no-op
|
| +// if the download has already been cancelled.
|
| +void MockDownloadManager::CancelDownload(int32 download_id) {
|
| +}
|
| +
|
| +// Called when there is an error in the download.
|
| +// |download_id| is the ID of the download.
|
| +// |size| is the number of bytes that are currently downloaded.
|
| +// |reason| is a download interrupt reason code.
|
| +void MockDownloadManager::OnDownloadInterrupted(int32 download_id, int64 size,
|
| + InterruptReason reason) {
|
| +}
|
| +
|
| +// Called from DownloadItem to handle the DownloadManager portion of a
|
| +// Cancel; should not be called from other locations.
|
| +void MockDownloadManager::DownloadCancelledInternal(DownloadItem* download) {
|
| +}
|
| +
|
| +// Called from a view when a user clicks a UI button or link.
|
| +void MockDownloadManager::RemoveDownload(int64 download_handle) {
|
| +}
|
| +
|
| +// Determine if the download is ready for completion, i.e. has had
|
| +// all data saved, and completed the filename determination and
|
| +// history insertion.
|
| +bool MockDownloadManager::IsDownloadReadyForCompletion(DownloadItem* download) {
|
| + return true;
|
| +}
|
| +
|
| +// If all pre-requisites have been met, complete download processing, i.e.
|
| +// do internal cleanup, file rename, and potentially auto-open.
|
| +// (Dangerous downloads still may block on user acceptance after this
|
| +// point.)
|
| +void MockDownloadManager::MaybeCompleteDownload(DownloadItem* download) {
|
| +}
|
| +
|
| +// Called when the download is renamed to its final name.
|
| +// |uniquifier| is a number used to make unique names for the file. It is
|
| +// only valid for the DANGEROUS_BUT_VALIDATED state of the download item.
|
| +void MockDownloadManager::OnDownloadRenamedToFinalName(int download_id,
|
| + const FilePath& full_path,
|
| + int uniquifier) {
|
| +}
|
| +
|
| +// Remove downloads after remove_begin (inclusive) and before remove_end
|
| +// (exclusive). You may pass in null Time values to do an unbounded delete
|
| +// in either direction.
|
| +int MockDownloadManager::RemoveDownloadsBetween(const base::Time remove_begin,
|
| + const base::Time remove_end) {
|
| + return 0;
|
| +}
|
| +
|
| +// Remove downloads will delete all downloads that have a timestamp that is
|
| +// the same or more recent than |remove_begin|. The number of downloads
|
| +// deleted is returned back to the caller.
|
| +int MockDownloadManager::RemoveDownloads(const base::Time remove_begin) {
|
| + return 0;
|
| +}
|
| +
|
| +// Remove all downloads will delete all downloads. The number of downloads
|
| +// deleted is returned back to the caller.
|
| +int MockDownloadManager::RemoveAllDownloads() {
|
| + return 1;
|
| +}
|
| +
|
| +// Final download manager transition for download: Update the download
|
| +// history and remove the download from |active_downloads_|.
|
| +void MockDownloadManager::DownloadCompleted(int32 download_id) {
|
| +}
|
| +
|
| +// Download the object at the URL. Used in cases such as "Save Link As..."
|
| +void MockDownloadManager::DownloadUrl(const GURL& url,
|
| + const GURL& referrer,
|
| + const std::string& referrer_encoding,
|
| + TabContents* tab_contents) {
|
| +}
|
| +
|
| +// Download the object at the URL and save it to the specified path. The
|
| +// download is treated as the temporary download and thus will not appear
|
| +// in the download history. Used in cases such as drag and drop.
|
| +void MockDownloadManager::DownloadUrlToFile(const GURL& url,
|
| + const GURL& referrer,
|
| + const std::string& referrer_encoding,
|
| + const DownloadSaveInfo& save_info,
|
| + TabContents* tab_contents) {
|
| +}
|
| +
|
| +// Allow objects to observe the download creation process.
|
| +void MockDownloadManager::AddObserver(Observer* observer) {
|
| +}
|
| +
|
| +// Remove a download observer from ourself.
|
| +void MockDownloadManager::RemoveObserver(Observer* observer) {
|
| +}
|
| +
|
| +// Called by the embedder, after creating the download manager, to let it know
|
| +// about downloads from previous runs of the browser.
|
| +void MockDownloadManager::OnPersistentStoreQueryComplete(
|
| + std::vector<DownloadPersistentStoreInfo>* entries) {
|
| +}
|
| +
|
| +// Called by the embedder, in response to
|
| +// DownloadManagerDelegate::AddItemToPersistentStore.
|
| +void MockDownloadManager::OnItemAddedToPersistentStore(int32 download_id,
|
| + int64 db_handle) {
|
| +}
|
| +
|
| +// Display a new download in the appropriate browser UI.
|
| +void MockDownloadManager::ShowDownloadInBrowser(DownloadItem* download) {
|
| +}
|
| +
|
| +// The number of in progress (including paused) downloads.
|
| +int MockDownloadManager::InProgressCount() const {
|
| + return 1;
|
| +}
|
| +
|
| +content::BrowserContext* MockDownloadManager::BrowserContext() {
|
| + return NULL;
|
| +}
|
| +
|
| +FilePath MockDownloadManager::LastDownloadPath() {
|
| + return FilePath();
|
| +}
|
| +
|
| +// Creates the download item. Must be called on the UI thread.
|
| +void MockDownloadManager::CreateDownloadItem(DownloadCreateInfo* info,
|
| + const DownloadRequestHandle& request_handle) {
|
| +}
|
| +
|
| +// Clears the last download path, used to initialize "save as" dialogs.
|
| +void MockDownloadManager::ClearLastDownloadPath() {
|
| +}
|
| +
|
| +// Called by the delegate after the save as dialog is closed.
|
| +void MockDownloadManager::FileSelected(const FilePath& path, void* params) {
|
| +}
|
| +void MockDownloadManager::FileSelectionCanceled(void* params) {
|
| +}
|
| +
|
| +// Called by the delegate if it delayed the download in
|
| +// DownloadManagerDelegate::ShouldStartDownload and now is ready.
|
| +void MockDownloadManager::RestartDownload(int32 download_id) {
|
| +}
|
| +
|
| +// Mark the download opened in the persistent store.
|
| +void MockDownloadManager::MarkDownloadOpened(DownloadItem* download) {
|
| +}
|
| +
|
| +// Checks whether downloaded files still exist. Updates state of downloads
|
| +// that refer to removed files. The check runs in the background and may
|
| +// finish asynchronously after this method returns.
|
| +void MockDownloadManager::CheckForHistoryFilesRemoval() {
|
| +}
|
| +
|
| +// Checks whether a downloaded file still exists and updates the file's state
|
| +// if the file is already removed. The check runs in the background and may
|
| +// finish asynchronously after this method returns.
|
| +void MockDownloadManager::CheckForFileRemoval(DownloadItem* download_item) {
|
| +}
|
| +
|
| +// Assert the named download item is on the correct queues
|
| +// in the DownloadManager. For debugging.
|
| +void MockDownloadManager::AssertQueueStateConsistent(DownloadItem* download) {
|
| +}
|
| +
|
| +// Get the download item from the history map. Useful after the item has
|
| +// been removed from the active map, or was retrieved from the history DB.
|
| +DownloadItem* MockDownloadManager::GetDownloadItem(int id) {
|
| + return NULL;
|
| +}
|
| +
|
| +// Called when Save Page download starts. Transfers ownership of |download|
|
| +// to the DownloadManager.
|
| +void MockDownloadManager::SavePageDownloadStarted(DownloadItem* download) {
|
| +}
|
| +
|
| +// Called when Save Page download is done.
|
| +void MockDownloadManager::SavePageDownloadFinished(DownloadItem* download) {
|
| +}
|
| +
|
| +// Get the download item from the active map. Useful when the item is not
|
| +// yet in the history map.
|
| +DownloadItem* MockDownloadManager::GetActiveDownloadItem(int id) {
|
| + return NULL;
|
| +}
|
| +
|
| +content::DownloadManagerDelegate* MockDownloadManager::delegate() const {
|
| + return delegate_;
|
| +}
|
| +
|
| +// For testing only. May be called from tests indirectly (through
|
| +// other for testing only methods).
|
| +void MockDownloadManager::SetDownloadManagerDelegate(
|
| + content::DownloadManagerDelegate* delegate) {
|
| +}
|
| +
|
| +DownloadId MockDownloadManager::GetNextId() {
|
| + return DownloadId(this, 1);
|
| +}
|
| +
|
| +void MockDownloadManager::ContinueDownloadWithPath(DownloadItem* download,
|
| + const FilePath& chosen_file) {
|
| +}
|
| +
|
| +// Retrieves the download from the |download_id|.
|
| +// Returns NULL if the download is not active.
|
| +DownloadItem* MockDownloadManager::GetActiveDownload(int32 download_id) {
|
| + return NULL;
|
| +}
|
| +
|
| +void MockDownloadManager::SetFileManager(DownloadFileManager* file_manager) {
|
| +}
|
|
|