Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/nacl_host/nacl_process_host.h" | 7 #include "chrome/browser/nacl_host/nacl_process_host.h" |
| 8 | 8 |
| 9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 internal_->sockets_for_renderer.push_back(pair[0]); | 220 internal_->sockets_for_renderer.push_back(pair[0]); |
| 221 internal_->sockets_for_sel_ldr.push_back(pair[1]); | 221 internal_->sockets_for_sel_ldr.push_back(pair[1]); |
| 222 SetCloseOnExec(pair[0]); | 222 SetCloseOnExec(pair[0]); |
| 223 SetCloseOnExec(pair[1]); | 223 SetCloseOnExec(pair[1]); |
| 224 } | 224 } |
| 225 | 225 |
| 226 // Launch the process | 226 // Launch the process |
| 227 if (!LaunchSelLdr()) { | 227 if (!LaunchSelLdr()) { |
| 228 return false; | 228 return false; |
| 229 } | 229 } |
| 230 | |
| 230 chrome_render_message_filter_ = chrome_render_message_filter; | 231 chrome_render_message_filter_ = chrome_render_message_filter; |
| 232 | |
| 233 // On success, we take responsibility for sending the reply. | |
| 231 reply_msg_ = reply_msg; | 234 reply_msg_ = reply_msg; |
| 232 | |
| 233 return true; | 235 return true; |
| 234 } | 236 } |
| 235 | 237 |
| 236 bool NaClProcessHost::LaunchSelLdr() { | 238 bool NaClProcessHost::LaunchSelLdr() { |
| 237 std::string channel_id = child_process_host()->CreateChannel(); | 239 std::string channel_id = child_process_host()->CreateChannel(); |
| 238 if (channel_id.empty()) | 240 if (channel_id.empty()) |
| 239 return false; | 241 return false; |
| 240 | 242 |
| 241 CommandLine::StringType nacl_loader_prefix; | 243 CommandLine::StringType nacl_loader_prefix; |
| 242 #if defined(OS_POSIX) | 244 #if defined(OS_POSIX) |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 } | 378 } |
| 377 | 379 |
| 378 void NaClProcessHost::OnProcessLaunched() { | 380 void NaClProcessHost::OnProcessLaunched() { |
| 379 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 381 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| 380 | 382 |
| 381 if (nacl_browser->IrtAvailable()) { | 383 if (nacl_browser->IrtAvailable()) { |
| 382 // The IRT is already open. Away we go. | 384 // The IRT is already open. Away we go. |
| 383 SendStart(nacl_browser->IrtFile()); | 385 SendStart(nacl_browser->IrtFile()); |
| 384 } else { | 386 } else { |
| 385 // We're waiting for the IRT to be open. | 387 // We're waiting for the IRT to be open. |
| 386 nacl_browser->MakeIrtAvailable(base::Bind(&NaClProcessHost::IrtReady, | 388 if (!nacl_browser->MakeIrtAvailable( |
| 387 weak_factory_.GetWeakPtr())); | 389 base::Bind(&NaClProcessHost::IrtReady, |
| 390 weak_factory_.GetWeakPtr()))) | |
| 391 delete this; | |
|
dmichael (off chromium)
2011/12/20 19:01:34
I'm a little uneasy about "delete this" here, espe
brettw
2011/12/21 22:06:54
Sorry this shouldn't have been in this CL (got two
| |
| 388 } | 392 } |
| 389 } | 393 } |
| 390 | 394 |
| 391 // The asynchronous attempt to get the IRT file open has completed. | 395 // The asynchronous attempt to get the IRT file open has completed. |
| 392 void NaClProcessHost::IrtReady() { | 396 void NaClProcessHost::IrtReady() { |
| 393 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); | 397 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| 394 | 398 |
| 395 if (nacl_browser->IrtAvailable()) { | 399 if (nacl_browser->IrtAvailable()) { |
| 396 SendStart(nacl_browser->IrtFile()); | 400 SendStart(nacl_browser->IrtFile()); |
| 397 } else { | 401 } else { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 #endif | 538 #endif |
| 535 | 539 |
| 536 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); | 540 Send(new NaClProcessMsg_Start(handles_for_sel_ldr)); |
| 537 internal_->sockets_for_sel_ldr.clear(); | 541 internal_->sockets_for_sel_ldr.clear(); |
| 538 } | 542 } |
| 539 | 543 |
| 540 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { | 544 bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 541 NOTREACHED() << "Invalid message with type = " << msg.type(); | 545 NOTREACHED() << "Invalid message with type = " << msg.type(); |
| 542 return false; | 546 return false; |
| 543 } | 547 } |
| OLD | NEW |