| 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 "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" | 5 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 ->AsWeakPtr(); | 130 ->AsWeakPtr(); |
| 131 utility_process_host_->SetName(l10n_util::GetStringUTF16( | 131 utility_process_host_->SetName(l10n_util::GetStringUTF16( |
| 132 IDS_UTILITY_PROCESS_SAFE_BROWSING_ZIP_FILE_ANALYZER_NAME)); | 132 IDS_UTILITY_PROCESS_SAFE_BROWSING_ZIP_FILE_ANALYZER_NAME)); |
| 133 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing); | 133 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing); |
| 134 // Wait for the startup notification before sending the main IPC to the | 134 // Wait for the startup notification before sending the main IPC to the |
| 135 // utility process, so that we can dup the file handle. | 135 // utility process, so that we can dup the file handle. |
| 136 } | 136 } |
| 137 | 137 |
| 138 void SandboxedZipAnalyzer::OnUtilityProcessStarted() { | 138 void SandboxedZipAnalyzer::OnUtilityProcessStarted() { |
| 139 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 139 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 140 base::ProcessHandle utility_process = | |
| 141 content::RenderProcessHost::run_renderer_in_process() ? | |
| 142 base::GetCurrentProcessHandle() : | |
| 143 utility_process_host_->GetData().handle; | |
| 144 | |
| 145 if (utility_process == base::kNullProcessHandle) { | |
| 146 DLOG(ERROR) << "Child process handle is null"; | |
| 147 } | |
| 148 utility_process_host_->Send( | 140 utility_process_host_->Send( |
| 149 new ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection( | 141 new ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection( |
| 150 IPC::TakeFileHandleForProcess(std::move(zip_file_), utility_process), | 142 IPC::TakePlatformFileForTransit(std::move(zip_file_)), |
| 151 IPC::GetPlatformFileForTransit(temp_file_.GetPlatformFile(), | 143 IPC::GetPlatformFileForTransit(temp_file_.GetPlatformFile(), |
| 152 false /* !close_source_handle */))); | 144 false /* !close_source_handle */))); |
| 153 } | 145 } |
| 154 | 146 |
| 155 void SandboxedZipAnalyzer::OnAnalyzeZipFileFinished( | 147 void SandboxedZipAnalyzer::OnAnalyzeZipFileFinished( |
| 156 const zip_analyzer::Results& results) { | 148 const zip_analyzer::Results& results) { |
| 157 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 149 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 158 if (callback_called_) | 150 if (callback_called_) |
| 159 return; | 151 return; |
| 160 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 152 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 161 base::Bind(callback_, results)); | 153 base::Bind(callback_, results)); |
| 162 callback_called_ = true; | 154 callback_called_ = true; |
| 163 CloseTemporaryFile(); | 155 CloseTemporaryFile(); |
| 164 } | 156 } |
| 165 | 157 |
| 166 } // namespace safe_browsing | 158 } // namespace safe_browsing |
| OLD | NEW |