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

Side by Side Diff: content/renderer/renderer_main_platform_delegate_win.cc

Issue 23687007: Remove redundant exit-detection code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« no previous file with comments | « content/ppapi_plugin/ppapi_thread.cc ('k') | no next file » | 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 "content/renderer/renderer_main_platform_delegate.h" 5 #include "content/renderer/renderer_main_platform_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 25 matching lines...) Expand all
36 void SkiaPreCacheFontCharacters(const LOGFONT& logfont, 36 void SkiaPreCacheFontCharacters(const LOGFONT& logfont,
37 const wchar_t* text, 37 const wchar_t* text,
38 unsigned int text_length) { 38 unsigned int text_length) {
39 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 39 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
40 if (render_thread_impl) { 40 if (render_thread_impl) {
41 render_thread_impl->PreCacheFontCharacters(logfont, 41 render_thread_impl->PreCacheFontCharacters(logfont,
42 string16(text, text_length)); 42 string16(text, text_length));
43 } 43 }
44 } 44 }
45 45
46 void InitExitInterceptions() {
47 // If code subsequently tries to exit using exit(), _exit(), abort(), or
48 // ExitProcess(), force a crash (since otherwise these would be silent
49 // terminations and fly under the radar).
50 base::win::SetShouldCrashOnProcessDetach(true);
51 base::win::SetAbortBehaviorForCrashReporting();
52 }
53
54 #if !defined(NDEBUG) 46 #if !defined(NDEBUG)
55 LRESULT CALLBACK WindowsHookCBT(int code, WPARAM w_param, LPARAM l_param) { 47 LRESULT CALLBACK WindowsHookCBT(int code, WPARAM w_param, LPARAM l_param) {
56 CHECK_NE(code, HCBT_CREATEWND) 48 CHECK_NE(code, HCBT_CREATEWND)
57 << "Should not be creating windows in the renderer!"; 49 << "Should not be creating windows in the renderer!";
58 return CallNextHookEx(NULL, code, w_param, l_param); 50 return CallNextHookEx(NULL, code, w_param, l_param);
59 } 51 }
60 #endif // !NDEBUG 52 #endif // !NDEBUG
61 53
62
63 } // namespace 54 } // namespace
64 55
65 RendererMainPlatformDelegate::RendererMainPlatformDelegate( 56 RendererMainPlatformDelegate::RendererMainPlatformDelegate(
66 const MainFunctionParams& parameters) 57 const MainFunctionParams& parameters)
67 : parameters_(parameters), 58 : parameters_(parameters),
68 sandbox_test_module_(NULL) { 59 sandbox_test_module_(NULL) {
69 } 60 }
70 61
71 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { 62 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() {
72 } 63 }
73 64
74 void RendererMainPlatformDelegate::PlatformInitialize() { 65 void RendererMainPlatformDelegate::PlatformInitialize() {
75 #if !defined(NDEBUG) 66 #if !defined(NDEBUG)
76 // Install a check that we're not creating windows in the renderer. See 67 // Install a check that we're not creating windows in the renderer. See
77 // http://crbug.com/230122 for background. TODO(scottmg): Ideally this would 68 // http://crbug.com/230122 for background. TODO(scottmg): Ideally this would
78 // check all threads in the renderer, but it currently only checks the main 69 // check all threads in the renderer, but it currently only checks the main
79 // thread. 70 // thread.
80 PCHECK( 71 PCHECK(
81 SetWindowsHookEx(WH_CBT, WindowsHookCBT, NULL, ::GetCurrentThreadId())); 72 SetWindowsHookEx(WH_CBT, WindowsHookCBT, NULL, ::GetCurrentThreadId()));
82 #endif // !NDEBUG 73 #endif // !NDEBUG
83 74
84 InitExitInterceptions();
85
86 const CommandLine& command_line = parameters_.command_line; 75 const CommandLine& command_line = parameters_.command_line;
87 76
88 #ifdef ENABLE_VTUNE_JIT_INTERFACE 77 #ifdef ENABLE_VTUNE_JIT_INTERFACE
89 if (command_line.HasSwitch(switches::kEnableVtune)) 78 if (command_line.HasSwitch(switches::kEnableVtune))
90 vTune::InitializeVtuneForV8(); 79 vTune::InitializeVtuneForV8();
91 #endif 80 #endif
92 81
93 // Be mindful of what resources you acquire here. They can be used by 82 // Be mindful of what resources you acquire here. They can be used by
94 // malicious code if the renderer gets compromised. 83 // malicious code if the renderer gets compromised.
95 bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox); 84 bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox);
96 85
97 if (!no_sandbox) { 86 if (!no_sandbox) {
98 // ICU DateFormat class (used in base/time_format.cc) needs to get the 87 // ICU DateFormat class (used in base/time_format.cc) needs to get the
99 // Olson timezone ID by accessing the registry keys under 88 // Olson timezone ID by accessing the registry keys under
100 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. 89 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones.
101 // After TimeZone::createDefault is called once here, the timezone ID is 90 // After TimeZone::createDefault is called once here, the timezone ID is
102 // cached and there's no more need to access the registry. If the sandbox 91 // cached and there's no more need to access the registry. If the sandbox
103 // is disabled, we don't have to make this dummy call. 92 // is disabled, we don't have to make this dummy call.
104 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); 93 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
105 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont); 94 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont);
106 skia::SetSkiaEnsureTypefaceCharactersAccessible( 95 skia::SetSkiaEnsureTypefaceCharactersAccessible(
107 SkiaPreCacheFontCharacters); 96 SkiaPreCacheFontCharacters);
108 } 97 }
109 } 98 }
110 99
111 void RendererMainPlatformDelegate::PlatformUninitialize() { 100 void RendererMainPlatformDelegate::PlatformUninitialize() {
112 // At this point we are shutting down in a normal code path, so undo our
113 // hack to crash on exit.
114 base::win::SetShouldCrashOnProcessDetach(false);
115 } 101 }
116 102
117 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { 103 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) {
118 const CommandLine& command_line = parameters_.command_line; 104 const CommandLine& command_line = parameters_.command_line;
119 105
120 DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString(); 106 DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString();
121 107
122 sandbox::TargetServices* target_services = 108 sandbox::TargetServices* target_services =
123 parameters_.sandbox_info->target_services; 109 parameters_.sandbox_info->target_services;
124 110
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 if (run_security_tests) { 149 if (run_security_tests) {
164 int test_count = 0; 150 int test_count = 0;
165 DVLOG(1) << "Running renderer security tests"; 151 DVLOG(1) << "Running renderer security tests";
166 BOOL result = run_security_tests(&test_count); 152 BOOL result = run_security_tests(&test_count);
167 CHECK(result) << "Test number " << test_count << " has failed."; 153 CHECK(result) << "Test number " << test_count << " has failed.";
168 } 154 }
169 } 155 }
170 } 156 }
171 157
172 } // namespace content 158 } // namespace content
OLDNEW
« no previous file with comments | « content/ppapi_plugin/ppapi_thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698