| 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/browser/download/download_file_manager.h" | 5 #include "content/browser/download/download_file_manager.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 ~TestDownloadManager() {} | 49 ~TestDownloadManager() {} |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class MockDownloadFileFactory : public content::DownloadFileFactory { | 52 class MockDownloadFileFactory : public content::DownloadFileFactory { |
| 53 | 53 |
| 54 public: | 54 public: |
| 55 MockDownloadFileFactory() {} | 55 MockDownloadFileFactory() {} |
| 56 virtual ~MockDownloadFileFactory() {} | 56 virtual ~MockDownloadFileFactory() {} |
| 57 | 57 |
| 58 virtual content::DownloadFile* CreateFile( | 58 virtual content::DownloadFile* CreateFile( |
| 59 DownloadCreateInfo* info, | 59 scoped_ptr<DownloadCreateInfo> info, |
| 60 scoped_ptr<content::ByteStreamReader> stream, | 60 scoped_ptr<content::ByteStreamReader> stream, |
| 61 content::DownloadManager* download_manager, | 61 content::DownloadManager* download_manager, |
| 62 bool calculate_hash, | 62 bool calculate_hash, |
| 63 const net::BoundNetLog& bound_net_log) OVERRIDE; | 63 const net::BoundNetLog& bound_net_log) OVERRIDE; |
| 64 | 64 |
| 65 MockDownloadFile* GetExistingFile(const DownloadId& id); | 65 MockDownloadFile* GetExistingFile(const DownloadId& id); |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 std::map<DownloadId, MockDownloadFile*> files_; | 68 std::map<DownloadId, MockDownloadFile*> files_; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 content::DownloadFile* MockDownloadFileFactory::CreateFile( | 71 content::DownloadFile* MockDownloadFileFactory::CreateFile( |
| 72 DownloadCreateInfo* info, | 72 scoped_ptr<DownloadCreateInfo> info, |
| 73 scoped_ptr<content::ByteStreamReader> stream, | 73 scoped_ptr<content::ByteStreamReader> stream, |
| 74 content::DownloadManager* download_manager, | 74 content::DownloadManager* download_manager, |
| 75 bool calculate_hash, | 75 bool calculate_hash, |
| 76 const net::BoundNetLog& bound_net_log) { | 76 const net::BoundNetLog& bound_net_log) { |
| 77 DCHECK(files_.end() == files_.find(info->download_id)); | 77 DCHECK(files_.end() == files_.find(info->download_id)); |
| 78 MockDownloadFile* created_file = new StrictMock<MockDownloadFile>(); | 78 MockDownloadFile* created_file = new StrictMock<MockDownloadFile>(); |
| 79 files_[info->download_id] = created_file; | 79 files_[info->download_id] = created_file; |
| 80 | 80 |
| 81 ON_CALL(*created_file, GetDownloadManager()) | 81 ON_CALL(*created_file, GetDownloadManager()) |
| 82 .WillByDefault(Return(download_manager)); | 82 .WillByDefault(Return(download_manager)); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 402 |
| 403 CleanUp(dummy_id); | 403 CleanUp(dummy_id); |
| 404 } | 404 } |
| 405 | 405 |
| 406 // TODO(ahendrickson) -- A test for download manager shutdown. | 406 // TODO(ahendrickson) -- A test for download manager shutdown. |
| 407 // Expected call sequence: | 407 // Expected call sequence: |
| 408 // OnDownloadManagerShutdown | 408 // OnDownloadManagerShutdown |
| 409 // DownloadFile::GetDownloadManager | 409 // DownloadFile::GetDownloadManager |
| 410 // DownloadFile::CancelDownloadRequest | 410 // DownloadFile::CancelDownloadRequest |
| 411 // DownloadFile::~DownloadFile | 411 // DownloadFile::~DownloadFile |
| OLD | NEW |