OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/engine/app/blimp_content_main_delegate.h" | 5 #include "blimp/engine/app/blimp_content_main_delegate.h" |
6 | 6 |
7 #include <string> | |
8 | |
9 #include "base/base_switches.h" | |
7 #include "base/command_line.h" | 10 #include "base/command_line.h" |
8 #include "base/files/file.h" | 11 #include "base/files/file.h" |
9 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/lazy_instance.h" | |
10 #include "base/logging.h" | 14 #include "base/logging.h" |
11 #include "base/path_service.h" | 15 #include "base/path_service.h" |
12 #include "blimp/engine/app/blimp_content_browser_client.h" | 16 #include "blimp/engine/app/blimp_content_browser_client.h" |
17 #include "blimp/engine/app/blimp_engine_crash_reporter_client.h" | |
13 #include "blimp/engine/renderer/blimp_content_renderer_client.h" | 18 #include "blimp/engine/renderer/blimp_content_renderer_client.h" |
19 #include "components/crash/content/app/breakpad_linux.h" | |
20 #include "components/crash/content/app/crash_reporter_client.h" | |
21 #include "content/public/common/content_switches.h" | |
14 #include "mojo/public/cpp/bindings/interface_request.h" | 22 #include "mojo/public/cpp/bindings/interface_request.h" |
15 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
16 | 24 |
17 namespace blimp { | 25 namespace blimp { |
18 namespace engine { | 26 namespace engine { |
27 | |
28 // Blimp engine crash client. This should be available globally and should be | |
29 // long lived. | |
30 base::LazyInstance<BlimpEngineCrashReporterClient> | |
31 g_blimp_engine_crash_reporter_client = LAZY_INSTANCE_INITIALIZER; | |
32 | |
19 namespace { | 33 namespace { |
20 void InitLogging() { | 34 void InitLogging() { |
21 // TODO(haibinlu): Remove this before release. | 35 // TODO(haibinlu): Remove this before release. |
22 // Enables a few verbose log by default. | 36 // Enables a few verbose log by default. |
23 if (!base::CommandLine::ForCurrentProcess()->HasSwitch("vmodule")) { | 37 if (!base::CommandLine::ForCurrentProcess()->HasSwitch("vmodule")) { |
24 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 38 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
25 "vmodule", "remote_channel_main=1"); | 39 "vmodule", "remote_channel_main=1"); |
26 } | 40 } |
27 | 41 |
28 logging::LoggingSettings settings; | 42 logging::LoggingSettings settings; |
(...skipping 15 matching lines...) Expand all Loading... | |
44 | 58 |
45 BlimpContentMainDelegate::~BlimpContentMainDelegate() {} | 59 BlimpContentMainDelegate::~BlimpContentMainDelegate() {} |
46 | 60 |
47 bool BlimpContentMainDelegate::BasicStartupComplete(int* exit_code) { | 61 bool BlimpContentMainDelegate::BasicStartupComplete(int* exit_code) { |
48 InitLogging(); | 62 InitLogging(); |
49 content::SetContentClient(&content_client_); | 63 content::SetContentClient(&content_client_); |
50 return false; | 64 return false; |
51 } | 65 } |
52 | 66 |
53 void BlimpContentMainDelegate::PreSandboxStartup() { | 67 void BlimpContentMainDelegate::PreSandboxStartup() { |
68 // Enable crash reporting for all processes, and initialize the crash | |
69 // reporter client. | |
70 crash_reporter::SetCrashReporterClient( | |
71 g_blimp_engine_crash_reporter_client.Pointer()); | |
72 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | |
73 const std::string process_type = | |
Kevin M
2016/05/02 22:05:31
No need to bind a variable, just use the switch ge
marcinjb
2016/05/03 18:06:58
Done.
| |
74 cmd->GetSwitchValueASCII(::switches::kProcessType); | |
75 cmd->AppendSwitch(::switches::kEnableCrashReporter); | |
76 breakpad::InitCrashReporter(process_type); | |
77 | |
54 InitializeResourceBundle(); | 78 InitializeResourceBundle(); |
55 } | 79 } |
56 | 80 |
57 void BlimpContentMainDelegate::InitializeResourceBundle() { | 81 void BlimpContentMainDelegate::InitializeResourceBundle() { |
58 base::FilePath pak_file; | 82 base::FilePath pak_file; |
59 bool pak_file_valid = PathService::Get(base::DIR_MODULE, &pak_file); | 83 bool pak_file_valid = PathService::Get(base::DIR_MODULE, &pak_file); |
60 CHECK(pak_file_valid); | 84 CHECK(pak_file_valid); |
61 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_engine.pak")); | 85 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_engine.pak")); |
62 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | 86 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
63 } | 87 } |
64 | 88 |
65 content::ContentBrowserClient* | 89 content::ContentBrowserClient* |
66 BlimpContentMainDelegate::CreateContentBrowserClient() { | 90 BlimpContentMainDelegate::CreateContentBrowserClient() { |
67 DCHECK(!browser_client_); | 91 DCHECK(!browser_client_); |
68 browser_client_.reset(new BlimpContentBrowserClient); | 92 browser_client_.reset(new BlimpContentBrowserClient); |
69 return browser_client_.get(); | 93 return browser_client_.get(); |
70 } | 94 } |
71 | 95 |
72 content::ContentRendererClient* | 96 content::ContentRendererClient* |
73 BlimpContentMainDelegate::CreateContentRendererClient() { | 97 BlimpContentMainDelegate::CreateContentRendererClient() { |
74 DCHECK(!renderer_client_); | 98 DCHECK(!renderer_client_); |
75 renderer_client_.reset(new BlimpContentRendererClient); | 99 renderer_client_.reset(new BlimpContentRendererClient); |
76 return renderer_client_.get(); | 100 return renderer_client_.get(); |
77 } | 101 } |
78 | 102 |
79 } // namespace engine | 103 } // namespace engine |
80 } // namespace blimp | 104 } // namespace blimp |
OLD | NEW |