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/nacl_host/nacl_process_host.h" | 5 #include "chrome/browser/nacl_host/nacl_process_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 cmd_line->AppendArgNative(script.value()); | 398 cmd_line->AppendArgNative(script.value()); |
399 } | 399 } |
400 cmd_line->AppendArg("--args"); | 400 cmd_line->AppendArg("--args"); |
401 const CommandLine::StringVector& argv = line->argv(); | 401 const CommandLine::StringVector& argv = line->argv(); |
402 for (size_t i = 0; i < argv.size(); i++) { | 402 for (size_t i = 0; i < argv.size(); i++) { |
403 cmd_line->AppendArgNative(argv[i]); | 403 cmd_line->AppendArgNative(argv[i]); |
404 } | 404 } |
405 return scoped_ptr<CommandLine>(cmd_line); | 405 return scoped_ptr<CommandLine>(cmd_line); |
406 } | 406 } |
407 #elif defined(OS_LINUX) | 407 #elif defined(OS_LINUX) |
408 class NaClProcessHost::NaClGdbWatchDelegate | 408 class NaClProcessHost::NaClGdbWatchDelegate : |
409 : public MessageLoopForIO::Watcher { | 409 public base::MessageLoopForIO::Watcher { |
410 public: | 410 public: |
411 // fd_write_ is used by nacl-gdb via /proc/browser_PID/fd/fd_write_ | 411 // fd_write_ is used by nacl-gdb via /proc/browser_PID/fd/fd_write_ |
412 NaClGdbWatchDelegate(int fd_read, int fd_write, | 412 NaClGdbWatchDelegate(int fd_read, int fd_write, |
413 const base::Closure& reply) | 413 const base::Closure& reply) |
414 : fd_read_(fd_read), | 414 : fd_read_(fd_read), |
415 fd_write_(fd_write), | 415 fd_write_(fd_write), |
416 reply_(reply) {} | 416 reply_(reply) {} |
417 | 417 |
418 virtual ~NaClGdbWatchDelegate() { | 418 virtual ~NaClGdbWatchDelegate() { |
419 if (HANDLE_EINTR(close(fd_read_)) != 0) | 419 if (HANDLE_EINTR(close(fd_read_)) != 0) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 cmd_line.AppendArgNative(script.value()); | 477 cmd_line.AppendArgNative(script.value()); |
478 } | 478 } |
479 // wait on fds[0] | 479 // wait on fds[0] |
480 // If the debugger crashes before attaching to the NaCl process, the user can | 480 // If the debugger crashes before attaching to the NaCl process, the user can |
481 // release resources by terminating the NaCl loader in Chrome Task Manager. | 481 // release resources by terminating the NaCl loader in Chrome Task Manager. |
482 nacl_gdb_watcher_delegate_.reset( | 482 nacl_gdb_watcher_delegate_.reset( |
483 new NaClGdbWatchDelegate( | 483 new NaClGdbWatchDelegate( |
484 fds[0], fds[1], | 484 fds[0], fds[1], |
485 base::Bind(&NaClProcessHost::OnNaClGdbAttached, | 485 base::Bind(&NaClProcessHost::OnNaClGdbAttached, |
486 weak_factory_.GetWeakPtr()))); | 486 weak_factory_.GetWeakPtr()))); |
487 MessageLoopForIO::current()->WatchFileDescriptor( | 487 base::MessageLoopForIO::current()->WatchFileDescriptor( |
488 fds[0], | 488 fds[0], |
489 true, | 489 true, |
490 MessageLoopForIO::WATCH_READ, | 490 base::MessageLoopForIO::WATCH_READ, |
491 &nacl_gdb_watcher_, | 491 &nacl_gdb_watcher_, |
492 nacl_gdb_watcher_delegate_.get()); | 492 nacl_gdb_watcher_delegate_.get()); |
493 return base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); | 493 return base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); |
494 } | 494 } |
495 | 495 |
496 void NaClProcessHost::OnNaClGdbAttached() { | 496 void NaClProcessHost::OnNaClGdbAttached() { |
497 wait_for_nacl_gdb_ = false; | 497 wait_for_nacl_gdb_ = false; |
498 nacl_gdb_watcher_.StopWatchingFileDescriptor(); | 498 nacl_gdb_watcher_.StopWatchingFileDescriptor(); |
499 nacl_gdb_watcher_delegate_.reset(); | 499 nacl_gdb_watcher_delegate_.reset(); |
500 OnProcessLaunched(); | 500 OnProcessLaunched(); |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 } else { | 988 } else { |
989 NaClStartDebugExceptionHandlerThread( | 989 NaClStartDebugExceptionHandlerThread( |
990 process_handle.Take(), info, | 990 process_handle.Take(), info, |
991 base::MessageLoopProxy::current(), | 991 base::MessageLoopProxy::current(), |
992 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 992 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
993 weak_factory_.GetWeakPtr())); | 993 weak_factory_.GetWeakPtr())); |
994 return true; | 994 return true; |
995 } | 995 } |
996 } | 996 } |
997 #endif | 997 #endif |
OLD | NEW |