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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
13 #include "chrome/common/chrome_utility_messages.h" | 13 #include "chrome/common/chrome_utility_messages.h" |
14 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 14 #include "chrome/common/safe_browsing/zip_analyzer_results.h" |
| 15 #include "chrome/grit/generated_resources.h" |
15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/child_process_data.h" | 17 #include "content/public/browser/child_process_data.h" |
17 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
19 #include "ipc/ipc_message_macros.h" | 20 #include "ipc/ipc_message_macros.h" |
20 #include "ipc/ipc_platform_file.h" | 21 #include "ipc/ipc_platform_file.h" |
| 22 #include "ui/base/l10n/l10n_util.h" |
21 | 23 |
22 using content::BrowserThread; | 24 using content::BrowserThread; |
23 | 25 |
24 namespace safe_browsing { | 26 namespace safe_browsing { |
25 | 27 |
26 SandboxedZipAnalyzer::SandboxedZipAnalyzer( | 28 SandboxedZipAnalyzer::SandboxedZipAnalyzer( |
27 const base::FilePath& zip_file, | 29 const base::FilePath& zip_file, |
28 const ResultCallback& result_callback) | 30 const ResultCallback& result_callback) |
29 : zip_file_name_(zip_file), | 31 : zip_file_name_(zip_file), |
30 callback_(result_callback), | 32 callback_(result_callback), |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 IPC_END_MESSAGE_MAP() | 110 IPC_END_MESSAGE_MAP() |
109 return handled; | 111 return handled; |
110 } | 112 } |
111 | 113 |
112 void SandboxedZipAnalyzer::StartProcessOnIOThread() { | 114 void SandboxedZipAnalyzer::StartProcessOnIOThread() { |
113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
114 utility_process_host_ = content::UtilityProcessHost::Create( | 116 utility_process_host_ = content::UtilityProcessHost::Create( |
115 this, | 117 this, |
116 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()) | 118 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()) |
117 ->AsWeakPtr(); | 119 ->AsWeakPtr(); |
| 120 utility_process_host_->SetName(l10n_util::GetStringUTF16( |
| 121 IDS_UTILITY_PROCESS_SAFE_BROWSING_ZIP_FILE_ANALYZER_NAME)); |
118 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing); | 122 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing); |
119 // Wait for the startup notification before sending the main IPC to the | 123 // Wait for the startup notification before sending the main IPC to the |
120 // utility process, so that we can dup the file handle. | 124 // utility process, so that we can dup the file handle. |
121 } | 125 } |
122 | 126 |
123 void SandboxedZipAnalyzer::OnUtilityProcessStarted() { | 127 void SandboxedZipAnalyzer::OnUtilityProcessStarted() { |
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
125 base::ProcessHandle utility_process = | 129 base::ProcessHandle utility_process = |
126 content::RenderProcessHost::run_renderer_in_process() ? | 130 content::RenderProcessHost::run_renderer_in_process() ? |
127 base::GetCurrentProcessHandle() : | 131 base::GetCurrentProcessHandle() : |
(...skipping 15 matching lines...) Expand all Loading... |
143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
144 if (callback_called_) | 148 if (callback_called_) |
145 return; | 149 return; |
146 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 150 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
147 base::Bind(callback_, results)); | 151 base::Bind(callback_, results)); |
148 callback_called_ = true; | 152 callback_called_ = true; |
149 CloseTemporaryFile(); | 153 CloseTemporaryFile(); |
150 } | 154 } |
151 | 155 |
152 } // namespace safe_browsing | 156 } // namespace safe_browsing |
OLD | NEW |