Chromium Code Reviews| 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..2949f908cb580b0d20c841af8cc60563be822819 |
| --- /dev/null |
| +++ b/content/test/test_file_error_injector.h |
| @@ -0,0 +1,45 @@ |
| +// 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" |
| +#include "net/base/net_errors.h" |
| + |
| +enum FileOperationCode { |
|
cbentzel
2012/02/24 01:54:37
Should this be in the content namespace?
ahendrickson
2012/02/24 22:48:39
Done.
|
| + FILE_OPERATION_INITIALIZE, |
| + FILE_OPERATION_WRITE, |
| + FILE_OPERATION_RENAME |
| +}; |
| + |
| +// Test helper for injecting errors into DownloadFile operations. |
| +// Must only be used on the FILE thread. |
|
cbentzel
2012/02/24 02:25:12
Comment not entirely true - constructor can be cal
ahendrickson
2012/02/24 22:48:39
Changed the comment.
|
| +class TestFileErrorInjector |
| + : public base::RefCountedThreadSafe<TestFileErrorInjector> { |
|
cbentzel
2012/02/24 02:25:12
Why does this need to be refcounted?
ahendrickson
2012/02/24 22:48:39
Because the DownloadFileWithError instances can ou
|
| + public: |
| + TestFileErrorInjector() {} |
| + |
| + static TestFileErrorInjector* Create(); |
| + |
| + virtual bool InjectError(int file_index, |
|
cbentzel
2012/02/24 02:25:12
Could this be simplified at all - especially since
ahendrickson
2012/02/24 22:48:39
I would like to be able to use this later, for aut
|
| + FileOperationCode operation, |
| + int operation_instance, |
| + net::Error net_error) = 0; |
| + |
| + virtual size_t CurrentFileCount() const = 0; |
| + virtual size_t FileCreationCount() const = 0; |
| + |
| + protected: |
| + // Here so we can derive from this class. |
| + virtual ~TestFileErrorInjector() {} |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<TestFileErrorInjector>; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TestFileErrorInjector); |
| +}; |
| + |
| +#endif // CONTENT_TEST_TEST_FILE_ERROR_INJECTOR_H_ |