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

Unified Diff: content/public/test/test_file_error_injector.h

Issue 10861002: Revert 152213 - Replace the DownloadFileManager with direct ownership of DownloadFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/test/mock_download_manager.h ('k') | content/public/test/test_file_error_injector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/test_file_error_injector.h
===================================================================
--- content/public/test/test_file_error_injector.h (revision 152281)
+++ content/public/test/test_file_error_injector.h (working copy)
@@ -6,22 +6,18 @@
#define CONTENT_PUBLIC_TEST_TEST_FILE_ERROR_INJECTOR_H_
#include <map>
-#include <set>
#include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/ref_counted.h"
#include "content/public/browser/download_interrupt_reasons.h"
-class DownloadManagerImpl;
class GURL;
namespace content {
class DownloadId;
class DownloadFileWithErrorsFactory;
-class DownloadManager;
// Test helper for injecting errors into download file operations.
// All errors for a download must be injected before it starts.
@@ -40,7 +36,7 @@
// FileErrorInfo b = { url2, ... };
//
// scoped_refptr<TestFileErrorInjector> injector =
-// TestFileErrorInjector::Create(download_manager);
+// TestFileErrorInjector::Create();
//
// injector->AddError(a);
// injector->AddError(b);
@@ -71,9 +67,7 @@
// Creates an instance. May only be called once.
// Lives until all callbacks (in the implementation) are complete and the
// creator goes out of scope.
- // TODO(rdsmith): Allow multiple calls for different download managers.
- static scoped_refptr<TestFileErrorInjector> Create(
- scoped_refptr<content::DownloadManager> download_manager);
+ static scoped_refptr<TestFileErrorInjector> Create();
// Adds an error.
// Must be called before |InjectErrors()| for a particular download file.
@@ -101,6 +95,9 @@
// Returns whether or not a file matching |url| has been created.
bool HadFile(const GURL& url) const;
+ // Gets the download ID associated with the file matching |url|.
+ const DownloadId GetId(const GURL& url) const;
+
// Resets the found file list.
void ClearFoundFiles();
@@ -109,20 +106,24 @@
private:
friend class base::RefCountedThreadSafe<TestFileErrorInjector>;
- typedef std::set<GURL> FileSet;
+ typedef std::map<GURL, DownloadId> FileMap;
- TestFileErrorInjector(
- scoped_refptr<content::DownloadManager> download_manager);
+ TestFileErrorInjector();
virtual ~TestFileErrorInjector();
+ void AddFactory(scoped_ptr<DownloadFileWithErrorsFactory> factory);
+
+ void InjectErrorsOnFileThread(ErrorMap map,
+ DownloadFileWithErrorsFactory* factory);
+
// Callbacks from the download file, to record lifetimes.
// These may be called on any thread.
- void RecordDownloadFileConstruction(const GURL& url);
+ void RecordDownloadFileConstruction(const GURL& url, DownloadId id);
void RecordDownloadFileDestruction(const GURL& url);
// These run on the UI thread.
- void DownloadFileCreated(GURL url);
+ void DownloadFileCreated(GURL url, DownloadId id);
void DestroyingDownloadFile(GURL url);
// All the data is used on the UI thread.
@@ -130,17 +131,14 @@
ErrorMap injected_errors_;
// Keep track of active DownloadFiles.
- FileSet files_;
+ FileMap files_;
// Keep track of found DownloadFiles.
- FileSet found_files_;
+ FileMap found_files_;
// The factory we created. May outlive this class.
DownloadFileWithErrorsFactory* created_factory_;
- // The download manager we set the factory on.
- scoped_refptr<DownloadManagerImpl> download_manager_;
-
DISALLOW_COPY_AND_ASSIGN(TestFileErrorInjector);
};
« no previous file with comments | « content/public/test/mock_download_manager.h ('k') | content/public/test/test_file_error_injector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698