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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "base/process/launch.h" | 35 #include "base/process/launch.h" |
36 #include "base/process/memory.h" | 36 #include "base/process/memory.h" |
37 #include "base/process/process.h" | 37 #include "base/process/process.h" |
38 #include "base/process/process_handle.h" | 38 #include "base/process/process_handle.h" |
39 #include "base/profiler/scoped_tracker.h" | 39 #include "base/profiler/scoped_tracker.h" |
40 #include "base/strings/string_number_conversions.h" | 40 #include "base/strings/string_number_conversions.h" |
41 #include "base/strings/string_util.h" | 41 #include "base/strings/string_util.h" |
42 #include "base/strings/stringprintf.h" | 42 #include "base/strings/stringprintf.h" |
43 #include "base/trace_event/trace_event.h" | 43 #include "base/trace_event/trace_event.h" |
44 #include "build/build_config.h" | 44 #include "build/build_config.h" |
45 #include "components/tracing/browser/trace_config_file.h" | 45 #include "components/tracing/common/trace_startup.h" |
46 #include "components/tracing/common/trace_to_console.h" | |
47 #include "components/tracing/common/tracing_switches.h" | |
48 #include "content/app/mojo/mojo_init.h" | 46 #include "content/app/mojo/mojo_init.h" |
49 #include "content/common/set_process_title.h" | 47 #include "content/common/set_process_title.h" |
50 #include "content/common/url_schemes.h" | 48 #include "content/common/url_schemes.h" |
51 #include "content/public/app/content_main.h" | 49 #include "content/public/app/content_main.h" |
52 #include "content/public/app/content_main_delegate.h" | 50 #include "content/public/app/content_main_delegate.h" |
53 #include "content/public/common/content_client.h" | 51 #include "content/public/common/content_client.h" |
54 #include "content/public/common/content_constants.h" | 52 #include "content/public/common/content_constants.h" |
55 #include "content/public/common/content_paths.h" | 53 #include "content/public/common/content_paths.h" |
56 #include "content/public/common/content_switches.h" | 54 #include "content/public/common/content_switches.h" |
57 #include "content/public/common/main_function_params.h" | 55 #include "content/public/common/main_function_params.h" |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 #if defined(OS_WIN) | 652 #if defined(OS_WIN) |
655 // Route stdio to parent console (if any) or create one. | 653 // Route stdio to parent console (if any) or create one. |
656 if (command_line.HasSwitch(switches::kEnableLogging)) | 654 if (command_line.HasSwitch(switches::kEnableLogging)) |
657 base::RouteStdioToConsole(true); | 655 base::RouteStdioToConsole(true); |
658 #endif | 656 #endif |
659 | 657 |
660 #if !defined(OS_ANDROID) | 658 #if !defined(OS_ANDROID) |
661 // Enable startup tracing asap to avoid early TRACE_EVENT calls being | 659 // Enable startup tracing asap to avoid early TRACE_EVENT calls being |
662 // ignored. For Android, startup tracing is enabled in an even earlier place | 660 // ignored. For Android, startup tracing is enabled in an even earlier place |
663 // content/app/android/library_loader_hooks.cc. | 661 // content/app/android/library_loader_hooks.cc. |
664 if (command_line.HasSwitch(switches::kTraceStartup)) { | 662 // Zygote process does not have file thread and renderer process on Win10 |
665 base::trace_event::TraceConfig trace_config( | 663 // cannot access the file system. |
666 command_line.GetSwitchValueASCII(switches::kTraceStartup), | 664 // TODO(ssid): Check if other processes can enable startup tracing here. |
667 base::trace_event::RECORD_UNTIL_FULL); | 665 bool can_access_file_system = (process_type != switches::kZygoteProcess && |
668 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 666 process_type != switches::kRendererProcess); |
669 trace_config, | 667 tracing::EnableStartupTracingIfNeeded(can_access_file_system); |
670 base::trace_event::TraceLog::RECORDING_MODE); | |
671 } else if (command_line.HasSwitch(switches::kTraceToConsole)) { | |
672 base::trace_event::TraceConfig trace_config = | |
673 tracing::GetConfigForTraceToConsole(); | |
674 LOG(ERROR) << "Start " << switches::kTraceToConsole | |
675 << " with CategoryFilter '" | |
676 << trace_config.ToCategoryFilterString() << "'."; | |
677 base::trace_event::TraceLog::GetInstance()->SetEnabled( | |
678 trace_config, | |
679 base::trace_event::TraceLog::RECORDING_MODE); | |
680 } else if (process_type != switches::kZygoteProcess && | |
681 process_type != switches::kRendererProcess) { | |
682 if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) { | |
683 // This checks kTraceConfigFile switch. | |
684 base::trace_event::TraceLog::GetInstance()->SetEnabled( | |
685 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), | |
686 base::trace_event::TraceLog::RECORDING_MODE); | |
687 } | |
688 } | |
689 #endif // !OS_ANDROID | 668 #endif // !OS_ANDROID |
690 | 669 |
691 #if defined(OS_WIN) | 670 #if defined(OS_WIN) |
692 // Enable exporting of events to ETW if requested on the command line. | 671 // Enable exporting of events to ETW if requested on the command line. |
693 if (command_line.HasSwitch(switches::kTraceExportEventsToETW)) | 672 if (command_line.HasSwitch(switches::kTraceExportEventsToETW)) |
694 base::trace_event::TraceEventETWExport::EnableETWExport(); | 673 base::trace_event::TraceEventETWExport::EnableETWExport(); |
695 #endif // OS_WIN | 674 #endif // OS_WIN |
696 | 675 |
697 #if !defined(OS_ANDROID) | 676 #if !defined(OS_ANDROID) |
698 // Android tracing started at the beginning of the method. | 677 // Android tracing started at the beginning of the method. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 | 881 |
903 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 882 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
904 }; | 883 }; |
905 | 884 |
906 // static | 885 // static |
907 ContentMainRunner* ContentMainRunner::Create() { | 886 ContentMainRunner* ContentMainRunner::Create() { |
908 return new ContentMainRunnerImpl(); | 887 return new ContentMainRunnerImpl(); |
909 } | 888 } |
910 | 889 |
911 } // namespace content | 890 } // namespace content |
OLD | NEW |