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 "content/public/app/content_main_runner.h" | 5 #include "content/public/app/content_main_runner.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/debugger.h" | 12 #include "base/debug/debugger.h" |
13 #include "base/debug/stack_trace.h" | |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/i18n/icu_util.h" | 15 #include "base/i18n/icu_util.h" |
15 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
19 #include "base/metrics/statistics_recorder.h" | 20 #include "base/metrics/statistics_recorder.h" |
20 #include "base/path_service.h" | 21 #include "base/path_service.h" |
21 #include "base/process/launch.h" | 22 #include "base/process/launch.h" |
22 #include "base/process/memory.h" | 23 #include "base/process/memory.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 // Various things break when you're using a locale where the decimal | 189 // Various things break when you're using a locale where the decimal |
189 // separator isn't a period. See e.g. bugs 22782 and 39964. For | 190 // separator isn't a period. See e.g. bugs 22782 and 39964. For |
190 // all processes except the browser process (where we call system | 191 // all processes except the browser process (where we call system |
191 // APIs that may rely on the correct locale for formatting numbers | 192 // APIs that may rely on the correct locale for formatting numbers |
192 // when presenting them to the user), reset the locale for numeric | 193 // when presenting them to the user), reset the locale for numeric |
193 // formatting. | 194 // formatting. |
194 // Note that this is not correct for plugin processes -- they can | 195 // Note that this is not correct for plugin processes -- they can |
195 // surface UI -- but it's likely they get this wrong too so why not. | 196 // surface UI -- but it's likely they get this wrong too so why not. |
196 setlocale(LC_NUMERIC, "C"); | 197 setlocale(LC_NUMERIC, "C"); |
197 #endif | 198 #endif |
199 | |
200 #if !defined(OFFICIAL_BUILD) | |
201 // Print stack traces to stderr when crashes occur. This opens up security | |
202 // holes so it should never be enabled for official builds. | |
203 base::debug::EnableInProcessStackDumping(); | |
204 #if defined(OS_WIN) | |
205 base::RouteStdioToConsole(false); | |
206 LoadLibraryA("dbghelp.dll"); | |
brucedawson
2016/04/18 23:07:00
What is the purpose of this LoadLibrary call? The
| |
207 #endif | |
208 #endif | |
198 } | 209 } |
199 | 210 |
200 class ContentClientInitializer { | 211 class ContentClientInitializer { |
201 public: | 212 public: |
202 static void Set(const std::string& process_type, | 213 static void Set(const std::string& process_type, |
203 ContentMainDelegate* delegate) { | 214 ContentMainDelegate* delegate) { |
204 ContentClient* content_client = GetContentClient(); | 215 ContentClient* content_client = GetContentClient(); |
205 #if !defined(CHROME_MULTIPLE_DLL_CHILD) | 216 #if !defined(CHROME_MULTIPLE_DLL_CHILD) |
206 if (process_type.empty()) { | 217 if (process_type.empty()) { |
207 if (delegate) | 218 if (delegate) |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 gfx::InitDeviceScaleFactor(gfx::GetDPIScale()); | 607 gfx::InitDeviceScaleFactor(gfx::GetDPIScale()); |
597 #endif | 608 #endif |
598 | 609 |
599 if (!GetContentClient()) | 610 if (!GetContentClient()) |
600 SetContentClient(&empty_content_client_); | 611 SetContentClient(&empty_content_client_); |
601 ContentClientInitializer::Set(process_type, delegate_); | 612 ContentClientInitializer::Set(process_type, delegate_); |
602 | 613 |
603 #if defined(OS_WIN) | 614 #if defined(OS_WIN) |
604 // Route stdio to parent console (if any) or create one. | 615 // Route stdio to parent console (if any) or create one. |
605 if (command_line.HasSwitch(switches::kEnableLogging)) | 616 if (command_line.HasSwitch(switches::kEnableLogging)) |
606 base::RouteStdioToConsole(); | 617 base::RouteStdioToConsole(true); |
607 #endif | 618 #endif |
608 | 619 |
609 // Enable startup tracing asap to avoid early TRACE_EVENT calls being | 620 // Enable startup tracing asap to avoid early TRACE_EVENT calls being |
610 // ignored. | 621 // ignored. |
611 if (command_line.HasSwitch(switches::kTraceStartup)) { | 622 if (command_line.HasSwitch(switches::kTraceStartup)) { |
612 base::trace_event::TraceConfig trace_config( | 623 base::trace_event::TraceConfig trace_config( |
613 command_line.GetSwitchValueASCII(switches::kTraceStartup), | 624 command_line.GetSwitchValueASCII(switches::kTraceStartup), |
614 base::trace_event::RECORD_UNTIL_FULL); | 625 base::trace_event::RECORD_UNTIL_FULL); |
615 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 626 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
616 trace_config, | 627 trace_config, |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
851 | 862 |
852 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 863 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
853 }; | 864 }; |
854 | 865 |
855 // static | 866 // static |
856 ContentMainRunner* ContentMainRunner::Create() { | 867 ContentMainRunner* ContentMainRunner::Create() { |
857 return new ContentMainRunnerImpl(); | 868 return new ContentMainRunnerImpl(); |
858 } | 869 } |
859 | 870 |
860 } // namespace content | 871 } // namespace content |
OLD | NEW |