| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_TEST_TEST_FILE_ERROR_INJECTOR_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_FILE_ERROR_INJECTOR_H_ |
| 6 #define CONTENT_PUBLIC_TEST_TEST_FILE_ERROR_INJECTOR_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_FILE_ERROR_INJECTOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "content/public/browser/download_interrupt_reasons.h" |
| 15 | 15 |
| 16 class GURL; | 16 class GURL; |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class DownloadId; | 20 class DownloadId; |
| 21 class DownloadFileWithErrorsFactory; | 21 class DownloadFileWithErrorsFactory; |
| 22 | 22 |
| 23 // Test helper for injecting errors into download file operations. | 23 // Test helper for injecting errors into download file operations. |
| 24 // All errors for a download must be injected before it starts. | 24 // All errors for a download must be injected before it starts. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 53 FILE_OPERATION_INITIALIZE, | 53 FILE_OPERATION_INITIALIZE, |
| 54 FILE_OPERATION_WRITE, | 54 FILE_OPERATION_WRITE, |
| 55 FILE_OPERATION_RENAME | 55 FILE_OPERATION_RENAME |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // Structure that encapsulates the information needed to inject a file error. | 58 // Structure that encapsulates the information needed to inject a file error. |
| 59 struct FileErrorInfo { | 59 struct FileErrorInfo { |
| 60 std::string url; // Full URL of the download. Identifies the download. | 60 std::string url; // Full URL of the download. Identifies the download. |
| 61 FileOperationCode code; // Operation to affect. | 61 FileOperationCode code; // Operation to affect. |
| 62 int operation_instance; // 0-based count of operation calls, for each code. | 62 int operation_instance; // 0-based count of operation calls, for each code. |
| 63 net::Error net_error; // Error to inject. | 63 content::DownloadInterruptReason error; // Error to inject. |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 typedef std::map<std::string, FileErrorInfo> ErrorMap; | 66 typedef std::map<std::string, FileErrorInfo> ErrorMap; |
| 67 | 67 |
| 68 // Creates an instance. May only be called once. | 68 // Creates an instance. May only be called once. |
| 69 // Lives until all callbacks (in the implementation) are complete and the | 69 // Lives until all callbacks (in the implementation) are complete and the |
| 70 // creator goes out of scope. | 70 // creator goes out of scope. |
| 71 static scoped_refptr<TestFileErrorInjector> Create(); | 71 static scoped_refptr<TestFileErrorInjector> Create(); |
| 72 | 72 |
| 73 // Adds an error. | 73 // Adds an error. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 // The factory we created. May outlive this class. | 140 // The factory we created. May outlive this class. |
| 141 DownloadFileWithErrorsFactory* created_factory_; | 141 DownloadFileWithErrorsFactory* created_factory_; |
| 142 | 142 |
| 143 DISALLOW_COPY_AND_ASSIGN(TestFileErrorInjector); | 143 DISALLOW_COPY_AND_ASSIGN(TestFileErrorInjector); |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 } // namespace content | 146 } // namespace content |
| 147 | 147 |
| 148 #endif // CONTENT_PUBLIC_TEST_TEST_FILE_ERROR_INJECTOR_H_ | 148 #endif // CONTENT_PUBLIC_TEST_TEST_FILE_ERROR_INJECTOR_H_ |
| OLD | NEW |