| 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 #include "content/public/test/test_file_error_injector.h" | 5 #include "content/public/test/test_file_error_injector.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 bool calculate_hash, | 35 bool calculate_hash, |
| 36 scoped_ptr<ByteStreamReader> stream, | 36 scoped_ptr<ByteStreamReader> stream, |
| 37 const net::BoundNetLog& bound_net_log, | 37 const net::BoundNetLog& bound_net_log, |
| 38 base::WeakPtr<DownloadDestinationObserver> observer, | 38 base::WeakPtr<DownloadDestinationObserver> observer, |
| 39 const TestFileErrorInjector::FileErrorInfo& error_info, | 39 const TestFileErrorInjector::FileErrorInfo& error_info, |
| 40 const ConstructionCallback& ctor_callback, | 40 const ConstructionCallback& ctor_callback, |
| 41 const DestructionCallback& dtor_callback); | 41 const DestructionCallback& dtor_callback); |
| 42 | 42 |
| 43 virtual ~DownloadFileWithErrors(); | 43 virtual ~DownloadFileWithErrors(); |
| 44 | 44 |
| 45 virtual void Initialize(const InitializeCallback& callback) OVERRIDE; | 45 virtual void Initialize(const InitializeCallback& callback) override; |
| 46 | 46 |
| 47 // DownloadFile interface. | 47 // DownloadFile interface. |
| 48 virtual DownloadInterruptReason AppendDataToFile( | 48 virtual DownloadInterruptReason AppendDataToFile( |
| 49 const char* data, size_t data_len) OVERRIDE; | 49 const char* data, size_t data_len) override; |
| 50 virtual void RenameAndUniquify( | 50 virtual void RenameAndUniquify( |
| 51 const base::FilePath& full_path, | 51 const base::FilePath& full_path, |
| 52 const RenameCompletionCallback& callback) OVERRIDE; | 52 const RenameCompletionCallback& callback) override; |
| 53 virtual void RenameAndAnnotate( | 53 virtual void RenameAndAnnotate( |
| 54 const base::FilePath& full_path, | 54 const base::FilePath& full_path, |
| 55 const RenameCompletionCallback& callback) OVERRIDE; | 55 const RenameCompletionCallback& callback) override; |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 // Error generating helper. | 58 // Error generating helper. |
| 59 DownloadInterruptReason ShouldReturnError( | 59 DownloadInterruptReason ShouldReturnError( |
| 60 TestFileErrorInjector::FileOperationCode code, | 60 TestFileErrorInjector::FileOperationCode code, |
| 61 DownloadInterruptReason original_error); | 61 DownloadInterruptReason original_error); |
| 62 | 62 |
| 63 // Determine whether to overwrite an operation with the given code | 63 // Determine whether to overwrite an operation with the given code |
| 64 // with a substitute error; if returns true, |*original_error| is | 64 // with a substitute error; if returns true, |*original_error| is |
| 65 // written with the error to use for overwriting. | 65 // written with the error to use for overwriting. |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 // DownloadFileFactory interface. | 259 // DownloadFileFactory interface. |
| 260 virtual DownloadFile* CreateFile( | 260 virtual DownloadFile* CreateFile( |
| 261 scoped_ptr<DownloadSaveInfo> save_info, | 261 scoped_ptr<DownloadSaveInfo> save_info, |
| 262 const base::FilePath& default_download_directory, | 262 const base::FilePath& default_download_directory, |
| 263 const GURL& url, | 263 const GURL& url, |
| 264 const GURL& referrer_url, | 264 const GURL& referrer_url, |
| 265 bool calculate_hash, | 265 bool calculate_hash, |
| 266 scoped_ptr<ByteStreamReader> stream, | 266 scoped_ptr<ByteStreamReader> stream, |
| 267 const net::BoundNetLog& bound_net_log, | 267 const net::BoundNetLog& bound_net_log, |
| 268 base::WeakPtr<DownloadDestinationObserver> observer) OVERRIDE; | 268 base::WeakPtr<DownloadDestinationObserver> observer) override; |
| 269 | 269 |
| 270 bool AddError( | 270 bool AddError( |
| 271 const TestFileErrorInjector::FileErrorInfo& error_info); | 271 const TestFileErrorInjector::FileErrorInfo& error_info); |
| 272 | 272 |
| 273 void ClearErrors(); | 273 void ClearErrors(); |
| 274 | 274 |
| 275 private: | 275 private: |
| 276 // Our injected error list, mapped by URL. One per file. | 276 // Our injected error list, mapped by URL. One per file. |
| 277 TestFileErrorInjector::ErrorMap injected_errors_; | 277 TestFileErrorInjector::ErrorMap injected_errors_; |
| 278 | 278 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 case FILE_OPERATION_RENAME_ANNOTATE: | 468 case FILE_OPERATION_RENAME_ANNOTATE: |
| 469 return "RENAME_ANNOTATE"; | 469 return "RENAME_ANNOTATE"; |
| 470 default: | 470 default: |
| 471 break; | 471 break; |
| 472 } | 472 } |
| 473 | 473 |
| 474 return "Unknown"; | 474 return "Unknown"; |
| 475 } | 475 } |
| 476 | 476 |
| 477 } // namespace content | 477 } // namespace content |
| OLD | NEW |