Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: components/nacl/browser/nacl_process_host.cc

Issue 286143010: Remove knowledge of nacl from content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "components/nacl/browser/nacl_process_host.h" 5 #include "components/nacl/browser/nacl_process_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 int exit_code = 0; 305 int exit_code = 0;
306 process_->GetTerminationStatus(false /* known_dead */, &exit_code); 306 process_->GetTerminationStatus(false /* known_dead */, &exit_code);
307 std::string message = 307 std::string message =
308 base::StringPrintf("NaCl process exited with status %i (0x%x)", 308 base::StringPrintf("NaCl process exited with status %i (0x%x)",
309 exit_code, exit_code); 309 exit_code, exit_code);
310 if (exit_code == 0) { 310 if (exit_code == 0) {
311 VLOG(1) << message; 311 VLOG(1) << message;
312 } else { 312 } else {
313 LOG(ERROR) << message; 313 LOG(ERROR) << message;
314 } 314 }
315 NaClBrowser::GetInstance()->OnProcessEnd(process_->GetData().id);
315 } 316 }
316 317
317 if (internal_->socket_for_renderer != NACL_INVALID_HANDLE) { 318 if (internal_->socket_for_renderer != NACL_INVALID_HANDLE) {
318 if (NaClClose(internal_->socket_for_renderer) != 0) { 319 if (NaClClose(internal_->socket_for_renderer) != 0) {
319 NOTREACHED() << "NaClClose() failed"; 320 NOTREACHED() << "NaClClose() failed";
320 } 321 }
321 } 322 }
322 323
323 if (internal_->socket_for_sel_ldr != NACL_INVALID_HANDLE) { 324 if (internal_->socket_for_sel_ldr != NACL_INVALID_HANDLE) {
324 if (NaClClose(internal_->socket_for_sel_ldr) != 0) { 325 if (NaClClose(internal_->socket_for_sel_ldr) != 0) {
(...skipping 19 matching lines...) Expand all
344 !CommandLine::ForCurrentProcess()->HasSwitch( 345 !CommandLine::ForCurrentProcess()->HasSwitch(
345 switches::kDisablePnaclCrashThrottling)) { 346 switches::kDisablePnaclCrashThrottling)) {
346 NaClBrowser::GetInstance()->OnProcessCrashed(); 347 NaClBrowser::GetInstance()->OnProcessCrashed();
347 } 348 }
348 } 349 }
349 350
350 // This is called at browser startup. 351 // This is called at browser startup.
351 // static 352 // static
352 void NaClProcessHost::EarlyStartup() { 353 void NaClProcessHost::EarlyStartup() {
353 NaClBrowser::GetInstance()->EarlyStartup(); 354 NaClBrowser::GetInstance()->EarlyStartup();
355 // Inform NaClBrowser that we exist and will have a debug port at some point.
354 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 356 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
355 // Open the IRT file early to make sure that it isn't replaced out from 357 // Open the IRT file early to make sure that it isn't replaced out from
356 // under us by autoupdate. 358 // under us by autoupdate.
357 NaClBrowser::GetInstance()->EnsureIrtAvailable(); 359 NaClBrowser::GetInstance()->EnsureIrtAvailable();
358 #endif 360 #endif
359 CommandLine* cmd = CommandLine::ForCurrentProcess(); 361 CommandLine* cmd = CommandLine::ForCurrentProcess();
360 UMA_HISTOGRAM_BOOLEAN( 362 UMA_HISTOGRAM_BOOLEAN(
361 "NaCl.nacl-gdb", 363 "NaCl.nacl-gdb",
362 !cmd->GetSwitchValuePath(switches::kNaClGdb).empty()); 364 !cmd->GetSwitchValuePath(switches::kNaClGdb).empty());
363 UMA_HISTOGRAM_BOOLEAN( 365 UMA_HISTOGRAM_BOOLEAN(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 if (!CommandLine::ForCurrentProcess()->GetSwitchValuePath( 486 if (!CommandLine::ForCurrentProcess()->GetSwitchValuePath(
485 switches::kNaClGdb).empty()) { 487 switches::kNaClGdb).empty()) {
486 LaunchNaClGdb(); 488 LaunchNaClGdb();
487 } 489 }
488 } 490 }
489 491
490 #if defined(OS_WIN) 492 #if defined(OS_WIN)
491 void NaClProcessHost::OnProcessLaunchedByBroker(base::ProcessHandle handle) { 493 void NaClProcessHost::OnProcessLaunchedByBroker(base::ProcessHandle handle) {
492 process_launched_by_broker_ = true; 494 process_launched_by_broker_ = true;
493 process_->SetHandle(handle); 495 process_->SetHandle(handle);
496 SetDebugStubPort(nacl::kGdbDebugStubPortUnknown);
494 if (!StartWithLaunchedProcess()) 497 if (!StartWithLaunchedProcess())
495 delete this; 498 delete this;
496 } 499 }
497 500
498 void NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker(bool success) { 501 void NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker(bool success) {
499 IPC::Message* reply = attach_debug_exception_handler_reply_msg_.release(); 502 IPC::Message* reply = attach_debug_exception_handler_reply_msg_.release();
500 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply, success); 503 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply, success);
501 Send(reply); 504 Send(reply);
502 } 505 }
503 #endif 506 #endif
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 DCHECK(reply_msg_); 762 DCHECK(reply_msg_);
760 if (nacl_host_message_filter_ != NULL && reply_msg_ != NULL) { 763 if (nacl_host_message_filter_ != NULL && reply_msg_ != NULL) {
761 NaClHostMsg_LaunchNaCl::WriteReplyParams( 764 NaClHostMsg_LaunchNaCl::WriteReplyParams(
762 reply_msg_, result, error_message); 765 reply_msg_, result, error_message);
763 nacl_host_message_filter_->Send(reply_msg_); 766 nacl_host_message_filter_->Send(reply_msg_);
764 nacl_host_message_filter_ = NULL; 767 nacl_host_message_filter_ = NULL;
765 reply_msg_ = NULL; 768 reply_msg_ = NULL;
766 } 769 }
767 } 770 }
768 771
769 void NaClProcessHost::SetDebugStubPort(uint16_t port) { 772 void NaClProcessHost::SetDebugStubPort(int port) {
770 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 773 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
771 if (nacl_browser->HasGdbDebugStubPortListener()) { 774 nacl_browser->SetProcessGdbDebugStubPort(process_->GetData().id, port);
772 nacl_browser->FireGdbDebugStubPortOpened(port);
773 }
774 // Set debug stub port on the process object.
775 process_->SetNaClDebugStubPort(port);
776 } 775 }
777 776
778 #if defined(OS_POSIX) 777 #if defined(OS_POSIX)
779 // TCP port we chose for NaCl debug stub. It can be any other number. 778 // TCP port we chose for NaCl debug stub. It can be any other number.
780 static const int kInitialDebugStubPort = 4014; 779 static const int kInitialDebugStubPort = 4014;
781 780
782 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { 781 net::SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() {
783 net::SocketDescriptor s = net::kInvalidSocket; 782 net::SocketDescriptor s = net::kInvalidSocket;
784 // We always try to allocate the default port first. If this fails, we then 783 // We always try to allocate the default port first. If this fails, we then
785 // allocate any available port. 784 // allocate any available port.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 process_handle.Take(), info, 1131 process_handle.Take(), info,
1133 base::MessageLoopProxy::current(), 1132 base::MessageLoopProxy::current(),
1134 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1133 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1135 weak_factory_.GetWeakPtr())); 1134 weak_factory_.GetWeakPtr()));
1136 return true; 1135 return true;
1137 } 1136 }
1138 } 1137 }
1139 #endif 1138 #endif
1140 1139
1141 } // namespace nacl 1140 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.h ('k') | content/browser/browser_child_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698