Index: content/test/test_file_error_injector.h |
diff --git a/content/test/test_file_error_injector.h b/content/test/test_file_error_injector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6708eaae9472444cdc34eaf475b87d08f8b9863c |
--- /dev/null |
+++ b/content/test/test_file_error_injector.h |
@@ -0,0 +1,47 @@ |
+// 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. |
+ |
+#ifndef CONTENT_TEST_TEST_FILE_ERROR_INJECTOR_H_ |
+#define CONTENT_TEST_TEST_FILE_ERROR_INJECTOR_H_ |
+#pragma once |
+ |
+#include "base/memory/ref_counted.h" |
cbentzel
2012/02/27 02:18:54
ref_counted no longer needed.
ahendrickson
2012/02/28 03:28:56
It is again.
|
+#include "net/base/net_errors.h" |
+ |
+namespace content { |
+ |
+enum FileOperationCode { |
cbentzel
2012/02/27 02:18:54
This seems pretty generic to be part of content na
ahendrickson
2012/02/28 03:28:56
Done.
|
+ FILE_OPERATION_INITIALIZE, |
+ FILE_OPERATION_WRITE, |
+ FILE_OPERATION_RENAME |
+}; |
+ |
+// Test helper for injecting errors into |DownloadFile| operations. |
+// All errors must be injected before |DownloadFile|s are created. |
cbentzel
2012/02/27 02:18:54
It might be clearer to have the API be like
Test
ahendrickson
2012/02/28 03:28:56
Done.
|
+// Any other operations must occur on the FILE thread. |
+// Will be owned by the |DownloadFileManager| via a |DownloadFileFactory| |
cbentzel
2012/02/27 02:18:54
Yeah - this ownership is still really strange - es
ahendrickson
2012/02/28 03:28:56
Switched to using RefCountedThreadSafe for the inj
|
+// instance. |
+class TestFileErrorInjector { |
+ public: |
+ TestFileErrorInjector() {} |
+ virtual ~TestFileErrorInjector() {} |
+ |
+ static TestFileErrorInjector* Create(); |
+ |
+ virtual bool InjectError(int file_index, |
+ FileOperationCode operation, |
+ int operation_instance, |
+ net::Error net_error) = 0; |
+ |
+ virtual size_t CurrentFileCount() const = 0; |
+ virtual size_t FileCreationCount() const = 0; |
+ virtual bool HasFile(int file_index) const = 0; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(TestFileErrorInjector); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_TEST_TEST_FILE_ERROR_INJECTOR_H_ |