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

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

Issue 1549633005: Move CloseHandle hook into base/debug. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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
« no previous file with comments | « chrome/app/BUILD.gn ('k') | chrome/app/close_handle_hook_win.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) 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/app/chrome_main_delegate.h" 5 #include "chrome/app/chrome_main_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "content/public/common/content_paths.h" 51 #include "content/public/common/content_paths.h"
52 #include "content/public/common/content_switches.h" 52 #include "content/public/common/content_switches.h"
53 #include "extensions/common/constants.h" 53 #include "extensions/common/constants.h"
54 #include "ui/base/resource/resource_bundle.h" 54 #include "ui/base/resource/resource_bundle.h"
55 #include "ui/base/ui_base_switches.h" 55 #include "ui/base/ui_base_switches.h"
56 56
57 #if defined(OS_WIN) 57 #if defined(OS_WIN)
58 #include <atlbase.h> 58 #include <atlbase.h>
59 #include <malloc.h> 59 #include <malloc.h>
60 #include <algorithm> 60 #include <algorithm>
61 #include "chrome/app/close_handle_hook_win.h" 61 #include "base/debug/close_handle_hook_win.h"
62 #include "chrome/common/child_process_logging.h" 62 #include "chrome/common/child_process_logging.h"
63 #include "chrome/common/v8_breakpad_support_win.h" 63 #include "chrome/common/v8_breakpad_support_win.h"
64 #include "components/crash/content/app/crashpad.h" 64 #include "components/crash/content/app/crashpad.h"
65 #include "sandbox/win/src/sandbox.h" 65 #include "sandbox/win/src/sandbox.h"
66 #include "ui/base/resource/resource_bundle_win.h" 66 #include "ui/base/resource/resource_bundle_win.h"
67 #endif 67 #endif
68 68
69 #if defined(OS_MACOSX) 69 #if defined(OS_MACOSX)
70 #include "base/mac/foundation_util.h" 70 #include "base/mac/foundation_util.h"
71 #include "chrome/app/chrome_main_mac.h" 71 #include "chrome/app/chrome_main_mac.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 187
188 bool IsSandboxedProcess() { 188 bool IsSandboxedProcess() {
189 typedef bool (*IsSandboxedProcessFunc)(); 189 typedef bool (*IsSandboxedProcessFunc)();
190 IsSandboxedProcessFunc is_sandboxed_process_func = 190 IsSandboxedProcessFunc is_sandboxed_process_func =
191 reinterpret_cast<IsSandboxedProcessFunc>( 191 reinterpret_cast<IsSandboxedProcessFunc>(
192 GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess")); 192 GetProcAddress(GetModuleHandle(NULL), "IsSandboxedProcess"));
193 return is_sandboxed_process_func && is_sandboxed_process_func(); 193 return is_sandboxed_process_func && is_sandboxed_process_func();
194 } 194 }
195 195
196 bool UseHooks() {
197 #if defined(ARCH_CPU_X86_64)
198 return false;
199 #elif defined(NDEBUG)
200 version_info::Channel channel = chrome::GetChannel();
201 if (channel == version_info::Channel::CANARY ||
202 channel == version_info::Channel::DEV) {
203 return true;
204 }
205
206 return false;
207 #else // NDEBUG
208 return true;
209 #endif
210 }
211
196 #endif // defined(OS_WIN) 212 #endif // defined(OS_WIN)
197 213
198 #if defined(OS_LINUX) 214 #if defined(OS_LINUX)
199 static void AdjustLinuxOOMScore(const std::string& process_type) { 215 static void AdjustLinuxOOMScore(const std::string& process_type) {
200 // Browsers and zygotes should still be killable, but killed last. 216 // Browsers and zygotes should still be killable, but killed last.
201 const int kZygoteScore = 0; 217 const int kZygoteScore = 0;
202 // The minimum amount to bump a score by. This is large enough that 218 // The minimum amount to bump a score by. This is large enough that
203 // even if it's translated into the old values, it will still go up 219 // even if it's translated into the old values, it will still go up
204 // by at least one. 220 // by at least one.
205 const int kScoreBump = 100; 221 const int kScoreBump = 100;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 #endif 511 #endif
496 #endif // OS_POSIX 512 #endif // OS_POSIX
497 513
498 #if defined(OS_WIN) 514 #if defined(OS_WIN)
499 // Must do this before any other usage of command line! 515 // Must do this before any other usage of command line!
500 if (HasDeprecatedArguments(command_line.GetCommandLineString())) { 516 if (HasDeprecatedArguments(command_line.GetCommandLineString())) {
501 *exit_code = 1; 517 *exit_code = 1;
502 return true; 518 return true;
503 } 519 }
504 520
505 InstallHandleHooks(); 521 if (UseHooks())
522 base::debug::InstallHandleHooks();
523 else
524 base::win::DisableHandleVerifier();
525
506 #endif 526 #endif
507 527
508 chrome::RegisterPathProvider(); 528 chrome::RegisterPathProvider();
509 #if defined(OS_CHROMEOS) 529 #if defined(OS_CHROMEOS)
510 chromeos::RegisterPathProvider(); 530 chromeos::RegisterPathProvider();
511 #endif 531 #endif
512 #if !defined(DISABLE_NACL) && defined(OS_LINUX) 532 #if !defined(DISABLE_NACL) && defined(OS_LINUX)
513 nacl::RegisterPathProvider(); 533 nacl::RegisterPathProvider();
514 #endif 534 #endif
515 535
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 if (SubprocessNeedsResourceBundle(process_type)) 905 if (SubprocessNeedsResourceBundle(process_type))
886 ResourceBundle::CleanupSharedInstance(); 906 ResourceBundle::CleanupSharedInstance();
887 #if !defined(OS_ANDROID) 907 #if !defined(OS_ANDROID)
888 logging::CleanupChromeLogging(); 908 logging::CleanupChromeLogging();
889 #else 909 #else
890 // Android doesn't use InitChromeLogging, so we close the log file manually. 910 // Android doesn't use InitChromeLogging, so we close the log file manually.
891 logging::CloseLogFile(); 911 logging::CloseLogFile();
892 #endif // !defined(OS_ANDROID) 912 #endif // !defined(OS_ANDROID)
893 913
894 #if defined(OS_WIN) 914 #if defined(OS_WIN)
895 RemoveHandleHooks(); 915 base::debug::RemoveHandleHooks();
896 #endif 916 #endif
897 } 917 }
898 918
899 #if defined(OS_MACOSX) 919 #if defined(OS_MACOSX)
900 bool ChromeMainDelegate::ProcessRegistersWithSystemProcess( 920 bool ChromeMainDelegate::ProcessRegistersWithSystemProcess(
901 const std::string& process_type) { 921 const std::string& process_type) {
902 #if defined(DISABLE_NACL) 922 #if defined(DISABLE_NACL)
903 return false; 923 return false;
904 #else 924 #else
905 return process_type == switches::kNaClLoaderProcess; 925 return process_type == switches::kNaClLoaderProcess;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 case version_info::Channel::CANARY: 1011 case version_info::Channel::CANARY:
992 return true; 1012 return true;
993 case version_info::Channel::DEV: 1013 case version_info::Channel::DEV:
994 case version_info::Channel::BETA: 1014 case version_info::Channel::BETA:
995 case version_info::Channel::STABLE: 1015 case version_info::Channel::STABLE:
996 default: 1016 default:
997 // Don't enable instrumentation. 1017 // Don't enable instrumentation.
998 return false; 1018 return false;
999 } 1019 }
1000 } 1020 }
OLDNEW
« no previous file with comments | « chrome/app/BUILD.gn ('k') | chrome/app/close_handle_hook_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698