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

Side by Side Diff: chrome/app/chrome_dll_main.cc

Issue 359001: Revert 30938 - Add support for getting the real process id from within the su... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « base/linux_util.h ('k') | chrome/browser/renderer_host/render_sandbox_host_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // TODO(port): the ifdefs in here are a first step towards trying to determine 5 // TODO(port): the ifdefs in here are a first step towards trying to determine
6 // the correct abstraction for all the OS functionality required at this 6 // the correct abstraction for all the OS functionality required at this
7 // stage of process initialization. It should not be taken as a final 7 // stage of process initialization. It should not be taken as a final
8 // abstraction. 8 // abstraction.
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 11
12 #if defined(OS_WIN) 12 #if defined(OS_WIN)
13 #include <algorithm> 13 #include <algorithm>
14 #include <atlbase.h> 14 #include <atlbase.h>
15 #include <atlapp.h> 15 #include <atlapp.h>
16 #include <malloc.h> 16 #include <malloc.h>
17 #include <new.h> 17 #include <new.h>
18 #elif defined(OS_POSIX) 18 #elif defined(OS_POSIX)
19 #include <locale.h> 19 #include <locale.h>
20 #include <signal.h> 20 #include <signal.h>
21 #include <sys/types.h>
21 #include <sys/stat.h> 22 #include <sys/stat.h>
22 #include <sys/types.h>
23 #include <unistd.h> 23 #include <unistd.h>
24 #endif 24 #endif
25 25
26 #if defined(OS_LINUX) 26 #if defined(OS_LINUX)
27 #include <gdk/gdk.h> 27 #include <gdk/gdk.h>
28 #include <glib.h> 28 #include <glib.h>
29 #include <gtk/gtk.h> 29 #include <gtk/gtk.h>
30 #include <stdlib.h>
31 #include <string.h> 30 #include <string.h>
32 #endif 31 #endif
33 32
34 #include "app/app_paths.h" 33 #include "app/app_paths.h"
35 #include "app/resource_bundle.h" 34 #include "app/resource_bundle.h"
36 #include "base/at_exit.h" 35 #include "base/at_exit.h"
37 #include "base/command_line.h" 36 #include "base/command_line.h"
38 #include "base/debug_util.h" 37 #include "base/debug_util.h"
39 #include "base/i18n/icu_util.h" 38 #include "base/i18n/icu_util.h"
40 #include "base/message_loop.h" 39 #include "base/message_loop.h"
(...skipping 11 matching lines...) Expand all
52 #include "chrome/common/chrome_paths.h" 51 #include "chrome/common/chrome_paths.h"
53 #include "chrome/common/chrome_switches.h" 52 #include "chrome/common/chrome_switches.h"
54 #include "chrome/common/logging_chrome.h" 53 #include "chrome/common/logging_chrome.h"
55 #include "chrome/common/main_function_params.h" 54 #include "chrome/common/main_function_params.h"
56 #include "chrome/common/sandbox_init_wrapper.h" 55 #include "chrome/common/sandbox_init_wrapper.h"
57 #include "ipc/ipc_switches.h" 56 #include "ipc/ipc_switches.h"
58 57
59 #if defined(OS_LINUX) 58 #if defined(OS_LINUX)
60 #include "base/nss_init.h" 59 #include "base/nss_init.h"
61 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" 60 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
62 #include "chrome/browser/zygote_host_linux.h"
63 #endif 61 #endif
64 62
65 #if defined(OS_MACOSX) 63 #if defined(OS_MACOSX)
66 #include "base/mac_util.h" 64 #include "base/mac_util.h"
67 #include "chrome/common/chrome_paths_internal.h" 65 #include "chrome/common/chrome_paths_internal.h"
68 #include "chrome/app/breakpad_mac.h" 66 #include "chrome/app/breakpad_mac.h"
69 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h" 67 #include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
70 #endif 68 #endif
71 69
72 #if defined(OS_POSIX) 70 #if defined(OS_POSIX)
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 base::ProcessId browser_pid; 378 base::ProcessId browser_pid;
381 if (process_type.empty()) { 379 if (process_type.empty()) {
382 browser_pid = base::GetCurrentProcId(); 380 browser_pid = base::GetCurrentProcId();
383 } else { 381 } else {
384 #if defined(OS_WIN) 382 #if defined(OS_WIN)
385 std::wstring channel_name = 383 std::wstring channel_name =
386 parsed_command_line.GetSwitchValue(switches::kProcessChannelID); 384 parsed_command_line.GetSwitchValue(switches::kProcessChannelID);
387 385
388 browser_pid = 386 browser_pid =
389 static_cast<base::ProcessId>(StringToInt(WideToASCII(channel_name))); 387 static_cast<base::ProcessId>(StringToInt(WideToASCII(channel_name)));
390 DCHECK_NE(browser_pid, 0); 388 DCHECK(browser_pid != 0);
391 #else 389 #else
392 browser_pid = base::GetCurrentProcId(); 390 browser_pid = base::GetCurrentProcId();
393 #endif 391 #endif
394 392
395 #if defined(OS_POSIX) 393 #if defined(OS_POSIX)
396 // When you hit Ctrl-C in a terminal running the browser 394 // When you hit Ctrl-C in a terminal running the browser
397 // process, a SIGINT is delivered to the entire process group. 395 // process, a SIGINT is delivered to the entire process group.
398 // When debugging the browser process via gdb, gdb catches the 396 // When debugging the browser process via gdb, gdb catches the
399 // SIGINT for the browser process (and dumps you back to the gdb 397 // SIGINT for the browser process (and dumps you back to the gdb
400 // console) but doesn't for the child processes, killing them. 398 // console) but doesn't for the child processes, killing them.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 &autorelease_pool); 572 &autorelease_pool);
575 rv = RendererMain(main_params); 573 rv = RendererMain(main_params);
576 } else { 574 } else {
577 rv = 0; 575 rv = 0;
578 } 576 }
579 #else 577 #else
580 NOTIMPLEMENTED(); 578 NOTIMPLEMENTED();
581 #endif 579 #endif
582 } else if (process_type.empty()) { 580 } else if (process_type.empty()) {
583 #if defined(OS_LINUX) 581 #if defined(OS_LINUX)
584 const char* sandbox_binary = NULL; 582 // Tickle the sandbox host so it forks now.
585 struct stat st; 583 Singleton<RenderSandboxHostLinux>().get();
586
587 // In Chromium branded builds, developers can set an environment variable to
588 // use the development sandbox. See
589 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment
590 if (stat("/proc/self/exe", &st) == 0 && st.st_uid == getuid())
591 sandbox_binary = getenv("CHROME_DEVEL_SANDBOX");
592
593 #if defined(LINUX_SANDBOX_PATH)
594 if (!sandbox_binary)
595 sandbox_binary = LINUX_SANDBOX_PATH;
596 #endif
597
598 std::string sandbox_cmd;
599 if (sandbox_binary)
600 sandbox_cmd = sandbox_binary;
601
602 // Tickle the sandbox host and zygote host so they fork now.
603 RenderSandboxHostLinux* shost = Singleton<RenderSandboxHostLinux>().get();
604 shost->Init(sandbox_cmd);
605 ZygoteHost* zhost = Singleton<ZygoteHost>().get();
606 zhost->Init(sandbox_cmd);
607 584
608 // We want to be sure to init NSPR on the main thread. 585 // We want to be sure to init NSPR on the main thread.
609 base::EnsureNSPRInit(); 586 base::EnsureNSPRInit();
610 587
611 g_thread_init(NULL); 588 g_thread_init(NULL);
612 // Glib type system initialization. Needed at least for gconf, 589 // Glib type system initialization. Needed at least for gconf,
613 // used in net/proxy/proxy_config_service_linux.cc. Most likely 590 // used in net/proxy/proxy_config_service_linux.cc. Most likely
614 // this is superfluous as gtk_init() ought to do this. It's 591 // this is superfluous as gtk_init() ought to do this. It's
615 // definitely harmless, so retained as a reminder of this 592 // definitely harmless, so retained as a reminder of this
616 // requirement for gconf. 593 // requirement for gconf.
617 g_type_init(); 594 g_type_init();
618 // gtk_init() can change |argc| and |argv|. 595 // gtk_init() can change |argc| and |argv|.
619 gtk_init(&argc, &argv); 596 gtk_init(&argc, &argv);
620 SetUpGLibLogHandler(); 597 SetUpGLibLogHandler();
621 #endif // defined(OS_LINUX) 598 #endif
622 599
623 ScopedOleInitializer ole_initializer; 600 ScopedOleInitializer ole_initializer;
624 rv = BrowserMain(main_params); 601 rv = BrowserMain(main_params);
625 } else { 602 } else {
626 NOTREACHED() << "Unknown process type"; 603 NOTREACHED() << "Unknown process type";
627 } 604 }
628 605
629 if (!process_type.empty()) { 606 if (!process_type.empty()) {
630 ResourceBundle::CleanupSharedInstance(); 607 ResourceBundle::CleanupSharedInstance();
631 } 608 }
632 609
633 #if defined(OS_WIN) 610 #if defined(OS_WIN)
634 #ifdef _CRTDBG_MAP_ALLOC 611 #ifdef _CRTDBG_MAP_ALLOC
635 _CrtDumpMemoryLeaks(); 612 _CrtDumpMemoryLeaks();
636 #endif // _CRTDBG_MAP_ALLOC 613 #endif // _CRTDBG_MAP_ALLOC
637 614
638 _Module.Term(); 615 _Module.Term();
639 #endif 616 #endif
640 617
641 logging::CleanupChromeLogging(); 618 logging::CleanupChromeLogging();
642 619
643 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) 620 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD)
644 // TODO(mark): See the TODO(mark) above at InitCrashReporter. 621 // TODO(mark): See the TODO(mark) above at InitCrashReporter.
645 DestructCrashReporter(); 622 DestructCrashReporter();
646 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD 623 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD
647 624
648 return rv; 625 return rv;
649 } 626 }
OLDNEW
« no previous file with comments | « base/linux_util.h ('k') | chrome/browser/renderer_host/render_sandbox_host_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698