Chromium Code Reviews| 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 "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 namespace blimp { | 25 namespace blimp { |
| 26 namespace engine { | 26 namespace engine { |
| 27 | 27 |
| 28 // Blimp engine crash client. This should be available globally and should be | 28 // Blimp engine crash client. This should be available globally and should be |
| 29 // long lived. | 29 // long lived. |
| 30 base::LazyInstance<BlimpEngineCrashReporterClient> | 30 base::LazyInstance<BlimpEngineCrashReporterClient> |
| 31 g_blimp_engine_crash_reporter_client = LAZY_INSTANCE_INITIALIZER; | 31 g_blimp_engine_crash_reporter_client = LAZY_INSTANCE_INITIALIZER; |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | |
| 35 BlimpContentMainDelegate* g_content_main_delegate = nullptr; | |
|
Kevin M
2016/05/05 20:28:51
I don't think we should be adding test-hook single
haibinlu
2016/05/05 22:41:36
Done.
| |
| 36 | |
| 34 void InitLogging() { | 37 void InitLogging() { |
| 35 // TODO(haibinlu): Remove this before release. | 38 // TODO(haibinlu): Remove this before release. |
| 36 // Enables a few verbose log by default. | 39 // Enables a few verbose log by default. |
| 37 if (!base::CommandLine::ForCurrentProcess()->HasSwitch("vmodule")) { | 40 if (!base::CommandLine::ForCurrentProcess()->HasSwitch("vmodule")) { |
| 38 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 41 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 39 "vmodule", "remote_channel_main=1"); | 42 "vmodule", "remote_channel_main=1"); |
| 40 } | 43 } |
| 41 | 44 |
| 42 logging::LoggingSettings settings; | 45 logging::LoggingSettings settings; |
| 43 base::FilePath log_filename; | 46 base::FilePath log_filename; |
| 44 PathService::Get(base::DIR_EXE, &log_filename); | 47 PathService::Get(base::DIR_EXE, &log_filename); |
| 45 log_filename = log_filename.AppendASCII("blimp_engine.log"); | 48 log_filename = log_filename.AppendASCII("blimp_engine.log"); |
| 46 settings.logging_dest = logging::LOG_TO_ALL; | 49 settings.logging_dest = logging::LOG_TO_ALL; |
| 47 settings.log_file = log_filename.value().c_str(); | 50 settings.log_file = log_filename.value().c_str(); |
| 48 settings.delete_old = logging::DELETE_OLD_LOG_FILE; | 51 settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
| 49 logging::InitLogging(settings); | 52 logging::InitLogging(settings); |
| 50 logging::SetLogItems(true, // Process ID | 53 logging::SetLogItems(true, // Process ID |
| 51 true, // Thread ID | 54 true, // Thread ID |
| 52 true, // Timestamp | 55 true, // Timestamp |
| 53 false); // Tick count | 56 false); // Tick count |
| 54 } | 57 } |
| 55 } // namespace | 58 } // namespace |
| 56 | 59 |
| 57 BlimpContentMainDelegate::BlimpContentMainDelegate() {} | 60 BlimpContentMainDelegate::BlimpContentMainDelegate() { |
| 61 DCHECK(!g_content_main_delegate); | |
| 62 g_content_main_delegate = this; | |
| 63 } | |
| 58 | 64 |
| 59 BlimpContentMainDelegate::~BlimpContentMainDelegate() {} | 65 BlimpContentMainDelegate::~BlimpContentMainDelegate() { |
| 66 DCHECK_EQ(this, g_content_main_delegate); | |
| 67 g_content_main_delegate = nullptr; | |
| 68 } | |
| 69 | |
| 70 BlimpContentBrowserClient* | |
| 71 BlimpContentMainDelegate::GetBlimpContentBrowserClient() { | |
| 72 return browser_client_.get(); | |
| 73 } | |
| 60 | 74 |
| 61 bool BlimpContentMainDelegate::BasicStartupComplete(int* exit_code) { | 75 bool BlimpContentMainDelegate::BasicStartupComplete(int* exit_code) { |
| 62 InitLogging(); | 76 InitLogging(); |
| 63 content::SetContentClient(&content_client_); | 77 content::SetContentClient(&content_client_); |
| 64 return false; | 78 return false; |
| 65 } | 79 } |
| 66 | 80 |
| 67 void BlimpContentMainDelegate::PreSandboxStartup() { | 81 void BlimpContentMainDelegate::PreSandboxStartup() { |
| 68 // Enable crash reporting for all processes, and initialize the crash | 82 // Enable crash reporting for all processes, and initialize the crash |
| 69 // reporter client. | 83 // reporter client. |
| 70 crash_reporter::SetCrashReporterClient( | 84 crash_reporter::SetCrashReporterClient( |
| 71 g_blimp_engine_crash_reporter_client.Pointer()); | 85 g_blimp_engine_crash_reporter_client.Pointer()); |
| 72 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 86 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 73 cmd->AppendSwitch(::switches::kEnableCrashReporter); | 87 cmd->AppendSwitch(::switches::kEnableCrashReporter); |
| 74 breakpad::InitCrashReporter( | 88 breakpad::InitCrashReporter( |
| 75 cmd->GetSwitchValueASCII(::switches::kProcessType)); | 89 cmd->GetSwitchValueASCII(::switches::kProcessType)); |
| 76 | 90 |
| 77 InitializeResourceBundle(); | 91 InitializeResourceBundle(); |
| 78 } | 92 } |
| 79 | 93 |
| 94 // static | |
| 95 BlimpContentMainDelegate* BlimpContentMainDelegate::GetInstanceForTesting() { | |
| 96 return g_content_main_delegate; | |
| 97 } | |
| 98 | |
| 80 void BlimpContentMainDelegate::InitializeResourceBundle() { | 99 void BlimpContentMainDelegate::InitializeResourceBundle() { |
| 81 base::FilePath pak_file; | 100 base::FilePath pak_file; |
| 82 bool pak_file_valid = PathService::Get(base::DIR_MODULE, &pak_file); | 101 bool pak_file_valid = PathService::Get(base::DIR_MODULE, &pak_file); |
| 83 CHECK(pak_file_valid); | 102 CHECK(pak_file_valid); |
| 84 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_engine.pak")); | 103 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_engine.pak")); |
| 85 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | 104 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
| 86 } | 105 } |
| 87 | 106 |
| 88 content::ContentBrowserClient* | 107 content::ContentBrowserClient* |
| 89 BlimpContentMainDelegate::CreateContentBrowserClient() { | 108 BlimpContentMainDelegate::CreateContentBrowserClient() { |
| 90 DCHECK(!browser_client_); | 109 DCHECK(!browser_client_); |
| 91 browser_client_.reset(new BlimpContentBrowserClient); | 110 browser_client_.reset(new BlimpContentBrowserClient); |
| 92 return browser_client_.get(); | 111 return browser_client_.get(); |
| 93 } | 112 } |
| 94 | 113 |
| 95 content::ContentRendererClient* | 114 content::ContentRendererClient* |
| 96 BlimpContentMainDelegate::CreateContentRendererClient() { | 115 BlimpContentMainDelegate::CreateContentRendererClient() { |
| 97 DCHECK(!renderer_client_); | 116 DCHECK(!renderer_client_); |
| 98 renderer_client_.reset(new BlimpContentRendererClient); | 117 renderer_client_.reset(new BlimpContentRendererClient); |
| 99 return renderer_client_.get(); | 118 return renderer_client_.get(); |
| 100 } | 119 } |
| 101 | 120 |
| 102 } // namespace engine | 121 } // namespace engine |
| 103 } // namespace blimp | 122 } // namespace blimp |
| OLD | NEW |