// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_TEST_DOWNLOAD_TEST_OBSERVER_H_ #define CONTENT_PUBLIC_TEST_DOWNLOAD_TEST_OBSERVER_H_ #include <stddef.h> #include <stdint.h> #include <set> #include <vector> #include "base/functional/callback_forward.h" #include "base/memory/raw_ptr.h" #include "base/run_loop.h" #include "components/download/public/common/download_interrupt_reasons.h" #include "components/download/public/common/download_item.h" #include "components/download/public/common/download_url_parameters.h" #include "content/public/browser/download_manager.h" namespace content { // Detects an arbitrary change on a download item. // TODO: Rewrite other observers to use this (or be replaced by it). class DownloadUpdatedObserver : public download::DownloadItem::Observer { … }; // Detects changes to the downloads after construction. // // Finishes when one of the following happens: // - A specified number of downloads change to a terminal state (defined // in derived classes). // - The download manager was shutdown. // // Callers may either probe for the finished state, or wait on it. class DownloadTestObserver : public DownloadManager::Observer, public download::DownloadItem::Observer { … }; class DownloadTestObserverTerminal : public DownloadTestObserver { … }; // Detects changes to the downloads after construction. // Finishes when a specified number of downloads change to the // IN_PROGRESS state, or when the download manager is destroyed. // Dangerous downloads are accepted. // Callers may either probe for the finished state, or wait on it. class DownloadTestObserverInProgress : public DownloadTestObserver { … }; class DownloadTestObserverInterrupted : public DownloadTestObserver { … }; // The WaitForFlush() method on this class returns after: // * There are no IN_PROGRESS download items remaining on the // DownloadManager. // * There have been two round trip messages through the file and // IO threads. // This almost certainly means that a Download cancel has propagated through // the system. class DownloadTestFlushObserver : public DownloadManager::Observer, public download::DownloadItem::Observer { … }; // Waits for a callback indicating that the download::DownloadItem is about to // be created, or that an error occurred and it won't be created. class DownloadTestItemCreationObserver : public base::RefCountedThreadSafe<DownloadTestItemCreationObserver> { … }; // Class for mornitoring whether a save package download finishes. class SavePackageFinishedObserver : public download::DownloadItem::Observer, public DownloadManager::Observer { … }; } // namespace content` #endif // CONTENT_PUBLIC_TEST_DOWNLOAD_TEST_OBSERVER_H_