| 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 <memory> |
| 7 #include <vector> | 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/location.h" | 13 #include "base/location.h" |
| 13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "chrome/common/chrome_utility_messages.h" | 16 #include "chrome/common/chrome_utility_messages.h" |
| 16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 PatchHost::~PatchHost() { | 55 PatchHost::~PatchHost() { |
| 55 } | 56 } |
| 56 | 57 |
| 57 void PatchHost::StartProcess(std::unique_ptr<IPC::Message> message) { | 58 void PatchHost::StartProcess(std::unique_ptr<IPC::Message> message) { |
| 58 // The DeltaUpdateOpPatchHost is not responsible for deleting the | 59 // The DeltaUpdateOpPatchHost is not responsible for deleting the |
| 59 // UtilityProcessHost object. | 60 // UtilityProcessHost object. |
| 60 content::UtilityProcessHost* host = content::UtilityProcessHost::Create( | 61 content::UtilityProcessHost* host = content::UtilityProcessHost::Create( |
| 61 this, base::ThreadTaskRunnerHandle::Get().get()); | 62 this, base::ThreadTaskRunnerHandle::Get().get()); |
| 62 host->SetName(l10n_util::GetStringUTF16( | 63 host->SetName(l10n_util::GetStringUTF16( |
| 63 IDS_UTILITY_PROCESS_COMPONENT_PATCHER_NAME)); | 64 IDS_UTILITY_PROCESS_COMPONENT_PATCHER_NAME)); |
| 64 host->DisableSandbox(); | |
| 65 host->Send(message.release()); | 65 host->Send(message.release()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool PatchHost::OnMessageReceived(const IPC::Message& message) { | 68 bool PatchHost::OnMessageReceived(const IPC::Message& message) { |
| 69 bool handled = true; | 69 bool handled = true; |
| 70 IPC_BEGIN_MESSAGE_MAP(PatchHost, message) | 70 IPC_BEGIN_MESSAGE_MAP(PatchHost, message) |
| 71 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_PatchFile_Finished, OnPatchFinished) | 71 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_PatchFile_Finished, OnPatchFinished) |
| 72 IPC_MESSAGE_UNHANDLED(handled = false) | 72 IPC_MESSAGE_UNHANDLED(handled = false) |
| 73 IPC_END_MESSAGE_MAP() | 73 IPC_END_MESSAGE_MAP() |
| 74 return handled; | 74 return handled; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 void ChromeOutOfProcessPatcher::Patch( | 97 void ChromeOutOfProcessPatcher::Patch( |
| 98 const std::string& operation, | 98 const std::string& operation, |
| 99 scoped_refptr<base::SequencedTaskRunner> task_runner, | 99 scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 100 const base::FilePath& input_abs_path, | 100 const base::FilePath& input_abs_path, |
| 101 const base::FilePath& patch_abs_path, | 101 const base::FilePath& patch_abs_path, |
| 102 const base::FilePath& output_abs_path, | 102 const base::FilePath& output_abs_path, |
| 103 base::Callback<void(int result)> callback) { | 103 base::Callback<void(int result)> callback) { |
| 104 host_ = new PatchHost(callback, task_runner); | 104 host_ = new PatchHost(callback, task_runner); |
| 105 IPC::PlatformFileForTransit input = IPC::TakePlatformFileForTransit( |
| 106 base::File( |
| 107 input_abs_path, base::File::FLAG_OPEN | base::File::FLAG_READ)); |
| 108 IPC::PlatformFileForTransit patch = IPC::TakePlatformFileForTransit( |
| 109 base::File( |
| 110 patch_abs_path, base::File::FLAG_OPEN | base::File::FLAG_READ)); |
| 111 IPC::PlatformFileForTransit output = IPC::TakePlatformFileForTransit( |
| 112 base::File( |
| 113 output_abs_path, |
| 114 base::File::FLAG_CREATE | |
| 115 base::File::FLAG_WRITE | |
| 116 base::File::FLAG_EXCLUSIVE_WRITE)); |
| 105 std::unique_ptr<IPC::Message> patch_message; | 117 std::unique_ptr<IPC::Message> patch_message; |
| 106 if (operation == update_client::kBsdiff) { | 118 if (operation == update_client::kBsdiff) { |
| 107 patch_message.reset(new ChromeUtilityMsg_PatchFileBsdiff( | 119 patch_message.reset(new ChromeUtilityMsg_PatchFileBsdiff( |
| 108 input_abs_path, patch_abs_path, output_abs_path)); | 120 input, patch, output)); |
| 109 } else if (operation == update_client::kCourgette) { | 121 } else if (operation == update_client::kCourgette) { |
| 110 patch_message.reset(new ChromeUtilityMsg_PatchFileCourgette( | 122 patch_message.reset(new ChromeUtilityMsg_PatchFileCourgette( |
| 111 input_abs_path, patch_abs_path, output_abs_path)); | 123 input, patch, output)); |
| 112 } else { | 124 } else { |
| 113 NOTREACHED(); | 125 NOTREACHED(); |
| 114 } | 126 } |
| 115 | 127 |
| 116 content::BrowserThread::PostTask( | 128 content::BrowserThread::PostTask( |
| 117 content::BrowserThread::IO, | 129 content::BrowserThread::IO, |
| 118 FROM_HERE, | 130 FROM_HERE, |
| 119 base::Bind( | 131 base::Bind( |
| 120 &PatchHost::StartProcess, host_, base::Passed(&patch_message))); | 132 &PatchHost::StartProcess, host_, base::Passed(&patch_message))); |
| 121 } | 133 } |
| 122 | 134 |
| 123 } // namespace component_updater | 135 } // namespace component_updater |
| OLD | NEW |