| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/component_updater/component_patcher_operation_out_of_pr
ocess.h" | 5 #include "chrome/browser/component_updater/component_patcher_operation_out_of_pr
ocess.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 base::Passed(&output_file))); | 54 base::Passed(&output_file))); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ChromeOutOfProcessPatcher::PatchOnIOThread(const std::string& operation, | 57 void ChromeOutOfProcessPatcher::PatchOnIOThread(const std::string& operation, |
| 58 base::File input_file, | 58 base::File input_file, |
| 59 base::File patch_file, | 59 base::File patch_file, |
| 60 base::File output_file) { | 60 base::File output_file) { |
| 61 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 61 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 62 DCHECK(!utility_process_mojo_client_); | 62 DCHECK(!utility_process_mojo_client_); |
| 63 | 63 |
| 64 const base::string16 utility_process_name = | 64 utility_process_mojo_client_ = base::MakeUnique< |
| 65 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_COMPONENT_PATCHER_NAME); | 65 content::UtilityProcessMojoClient<chrome::mojom::FilePatcher>>( |
| 66 | 66 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_COMPONENT_PATCHER_NAME)); |
| 67 utility_process_mojo_client_.reset( | |
| 68 new content::UtilityProcessMojoClient<chrome::mojom::FilePatcher>( | |
| 69 utility_process_name)); | |
| 70 utility_process_mojo_client_->set_error_callback( | 67 utility_process_mojo_client_->set_error_callback( |
| 71 base::Bind(&ChromeOutOfProcessPatcher::PatchDone, this, -1)); | 68 base::Bind(&ChromeOutOfProcessPatcher::PatchDone, this, -1)); |
| 72 | 69 |
| 73 utility_process_mojo_client_->Start(); // Start the utility process. | 70 utility_process_mojo_client_->Start(); // Start the utility process. |
| 74 | 71 |
| 75 if (operation == update_client::kBsdiff) { | 72 if (operation == update_client::kBsdiff) { |
| 76 utility_process_mojo_client_->service()->PatchFileBsdiff( | 73 utility_process_mojo_client_->service()->PatchFileBsdiff( |
| 77 std::move(input_file), std::move(patch_file), std::move(output_file), | 74 std::move(input_file), std::move(patch_file), std::move(output_file), |
| 78 base::Bind(&ChromeOutOfProcessPatcher::PatchDone, this)); | 75 base::Bind(&ChromeOutOfProcessPatcher::PatchDone, this)); |
| 79 } else if (operation == update_client::kCourgette) { | 76 } else if (operation == update_client::kCourgette) { |
| 80 utility_process_mojo_client_->service()->PatchFileCourgette( | 77 utility_process_mojo_client_->service()->PatchFileCourgette( |
| 81 std::move(input_file), std::move(patch_file), std::move(output_file), | 78 std::move(input_file), std::move(patch_file), std::move(output_file), |
| 82 base::Bind(&ChromeOutOfProcessPatcher::PatchDone, this)); | 79 base::Bind(&ChromeOutOfProcessPatcher::PatchDone, this)); |
| 83 } else { | 80 } else { |
| 84 NOTREACHED(); | 81 NOTREACHED(); |
| 85 } | 82 } |
| 86 } | 83 } |
| 87 | 84 |
| 88 void ChromeOutOfProcessPatcher::PatchDone(int result) { | 85 void ChromeOutOfProcessPatcher::PatchDone(int result) { |
| 89 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 86 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 90 | 87 |
| 91 utility_process_mojo_client_.reset(); // Terminate the utility process. | 88 utility_process_mojo_client_.reset(); // Terminate the utility process. |
| 92 task_runner_->PostTask(FROM_HERE, base::Bind(callback_, result)); | 89 task_runner_->PostTask(FROM_HERE, base::Bind(callback_, result)); |
| 93 } | 90 } |
| 94 | 91 |
| 95 } // namespace component_updater | 92 } // namespace component_updater |
| OLD | NEW |