| 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 22 matching lines...) Expand all Loading... |
| 33 const GURL& url, | 33 const GURL& url, |
| 34 const GURL& referrer_url, | 34 const GURL& referrer_url, |
| 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 ~DownloadFileWithErrors() override; |
| 44 | 44 |
| 45 virtual void Initialize(const InitializeCallback& callback) override; | 45 void Initialize(const InitializeCallback& callback) override; |
| 46 | 46 |
| 47 // DownloadFile interface. | 47 // DownloadFile interface. |
| 48 virtual DownloadInterruptReason AppendDataToFile( | 48 DownloadInterruptReason AppendDataToFile(const char* data, |
| 49 const char* data, size_t data_len) override; | 49 size_t data_len) override; |
| 50 virtual void RenameAndUniquify( | 50 void RenameAndUniquify(const base::FilePath& full_path, |
| 51 const base::FilePath& full_path, | 51 const RenameCompletionCallback& callback) override; |
| 52 const RenameCompletionCallback& callback) override; | 52 void RenameAndAnnotate(const base::FilePath& full_path, |
| 53 virtual void RenameAndAnnotate( | 53 const RenameCompletionCallback& callback) override; |
| 54 const base::FilePath& full_path, | |
| 55 const RenameCompletionCallback& callback) override; | |
| 56 | 54 |
| 57 private: | 55 private: |
| 58 // Error generating helper. | 56 // Error generating helper. |
| 59 DownloadInterruptReason ShouldReturnError( | 57 DownloadInterruptReason ShouldReturnError( |
| 60 TestFileErrorInjector::FileOperationCode code, | 58 TestFileErrorInjector::FileOperationCode code, |
| 61 DownloadInterruptReason original_error); | 59 DownloadInterruptReason original_error); |
| 62 | 60 |
| 63 // Determine whether to overwrite an operation with the given code | 61 // Determine whether to overwrite an operation with the given code |
| 64 // with a substitute error; if returns true, |*original_error| is | 62 // with a substitute error; if returns true, |*original_error| is |
| 65 // written with the error to use for overwriting. | 63 // written with the error to use for overwriting. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 245 } |
| 248 | 246 |
| 249 } // namespace | 247 } // namespace |
| 250 | 248 |
| 251 // A factory for constructing DownloadFiles that inject errors. | 249 // A factory for constructing DownloadFiles that inject errors. |
| 252 class DownloadFileWithErrorsFactory : public DownloadFileFactory { | 250 class DownloadFileWithErrorsFactory : public DownloadFileFactory { |
| 253 public: | 251 public: |
| 254 DownloadFileWithErrorsFactory( | 252 DownloadFileWithErrorsFactory( |
| 255 const DownloadFileWithErrors::ConstructionCallback& ctor_callback, | 253 const DownloadFileWithErrors::ConstructionCallback& ctor_callback, |
| 256 const DownloadFileWithErrors::DestructionCallback& dtor_callback); | 254 const DownloadFileWithErrors::DestructionCallback& dtor_callback); |
| 257 virtual ~DownloadFileWithErrorsFactory(); | 255 ~DownloadFileWithErrorsFactory() override; |
| 258 | 256 |
| 259 // DownloadFileFactory interface. | 257 // DownloadFileFactory interface. |
| 260 virtual DownloadFile* CreateFile( | 258 DownloadFile* CreateFile( |
| 261 scoped_ptr<DownloadSaveInfo> save_info, | 259 scoped_ptr<DownloadSaveInfo> save_info, |
| 262 const base::FilePath& default_download_directory, | 260 const base::FilePath& default_download_directory, |
| 263 const GURL& url, | 261 const GURL& url, |
| 264 const GURL& referrer_url, | 262 const GURL& referrer_url, |
| 265 bool calculate_hash, | 263 bool calculate_hash, |
| 266 scoped_ptr<ByteStreamReader> stream, | 264 scoped_ptr<ByteStreamReader> stream, |
| 267 const net::BoundNetLog& bound_net_log, | 265 const net::BoundNetLog& bound_net_log, |
| 268 base::WeakPtr<DownloadDestinationObserver> observer) override; | 266 base::WeakPtr<DownloadDestinationObserver> observer) override; |
| 269 | 267 |
| 270 bool AddError( | 268 bool AddError( |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 case FILE_OPERATION_RENAME_ANNOTATE: | 466 case FILE_OPERATION_RENAME_ANNOTATE: |
| 469 return "RENAME_ANNOTATE"; | 467 return "RENAME_ANNOTATE"; |
| 470 default: | 468 default: |
| 471 break; | 469 break; |
| 472 } | 470 } |
| 473 | 471 |
| 474 return "Unknown"; | 472 return "Unknown"; |
| 475 } | 473 } |
| 476 | 474 |
| 477 } // namespace content | 475 } // namespace content |
| OLD | NEW |