| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "blimp/engine/app/blimp_content_main_delegate.h" | |
| 6 | |
| 7 #include "base/base_switches.h" | |
| 8 #include "base/command_line.h" | |
| 9 #include "base/files/file.h" | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/lazy_instance.h" | |
| 12 #include "base/logging.h" | |
| 13 #include "base/path_service.h" | |
| 14 #include "blimp/engine/app/blimp_content_browser_client.h" | |
| 15 #include "blimp/engine/app/blimp_engine_crash_reporter_client.h" | |
| 16 #include "blimp/engine/renderer/blimp_content_renderer_client.h" | |
| 17 // TODO(marcinjb): Reenable gncheck for breakpad_linux.h after | |
| 18 // http://crbug.com/466890 is resolved. | |
| 19 #include "components/crash/content/app/breakpad_linux.h" // nogncheck | |
| 20 #include "components/crash/content/app/crash_reporter_client.h" | |
| 21 #include "content/public/common/content_switches.h" | |
| 22 #include "mojo/public/cpp/bindings/interface_request.h" | |
| 23 #include "ui/base/resource/resource_bundle.h" | |
| 24 | |
| 25 namespace blimp { | |
| 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 | |
| 33 namespace { | |
| 34 void InitLogging() { | |
| 35 logging::LoggingSettings settings; | |
| 36 base::FilePath log_filename; | |
| 37 PathService::Get(base::DIR_EXE, &log_filename); | |
| 38 log_filename = log_filename.AppendASCII("blimp_engine.log"); | |
| 39 settings.logging_dest = logging::LOG_TO_ALL; | |
| 40 settings.log_file = log_filename.value().c_str(); | |
| 41 settings.delete_old = logging::DELETE_OLD_LOG_FILE; | |
| 42 logging::InitLogging(settings); | |
| 43 logging::SetLogItems(true, // Process ID | |
| 44 true, // Thread ID | |
| 45 true, // Timestamp | |
| 46 false); // Tick count | |
| 47 } | |
| 48 } // namespace | |
| 49 | |
| 50 BlimpContentMainDelegate::BlimpContentMainDelegate() {} | |
| 51 | |
| 52 BlimpContentMainDelegate::~BlimpContentMainDelegate() {} | |
| 53 | |
| 54 bool BlimpContentMainDelegate::BasicStartupComplete(int* exit_code) { | |
| 55 InitLogging(); | |
| 56 content::SetContentClient(&content_client_); | |
| 57 return false; | |
| 58 } | |
| 59 | |
| 60 void BlimpContentMainDelegate::PreSandboxStartup() { | |
| 61 // Enable crash reporting for all processes, and initialize the crash | |
| 62 // reporter client. | |
| 63 crash_reporter::SetCrashReporterClient( | |
| 64 g_blimp_engine_crash_reporter_client.Pointer()); | |
| 65 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | |
| 66 cmd->AppendSwitch(::switches::kEnableCrashReporter); | |
| 67 breakpad::InitCrashReporter( | |
| 68 cmd->GetSwitchValueASCII(::switches::kProcessType)); | |
| 69 | |
| 70 InitializeResourceBundle(); | |
| 71 } | |
| 72 | |
| 73 void BlimpContentMainDelegate::InitializeResourceBundle() { | |
| 74 base::FilePath pak_file; | |
| 75 bool pak_file_valid = PathService::Get(base::DIR_MODULE, &pak_file); | |
| 76 CHECK(pak_file_valid); | |
| 77 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_engine.pak")); | |
| 78 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | |
| 79 } | |
| 80 | |
| 81 content::ContentBrowserClient* | |
| 82 BlimpContentMainDelegate::CreateContentBrowserClient() { | |
| 83 DCHECK(!browser_client_); | |
| 84 browser_client_.reset(new BlimpContentBrowserClient); | |
| 85 return browser_client_.get(); | |
| 86 } | |
| 87 | |
| 88 content::ContentRendererClient* | |
| 89 BlimpContentMainDelegate::CreateContentRendererClient() { | |
| 90 DCHECK(!renderer_client_); | |
| 91 renderer_client_.reset(new BlimpContentRendererClient); | |
| 92 return renderer_client_.get(); | |
| 93 } | |
| 94 | |
| 95 } // namespace engine | |
| 96 } // namespace blimp | |
| OLD | NEW |