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

Unified Diff: content/test/test_file_error_injector.h

Issue 9426029: Test file errors in downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplified injector classes further. Created 8 years, 10 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
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_

Powered by Google App Engine
This is Rietveld 408576698