| 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" | |
| 10 #include "base/command_line.h" | |
| 11 #include "base/files/file.h" | 7 #include "base/files/file.h" |
| 12 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 13 #include "base/lazy_instance.h" | |
| 14 #include "base/logging.h" | 9 #include "base/logging.h" |
| 15 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 16 #include "blimp/common/compositor/blimp_image_serialization_processor.h" | 11 #include "blimp/common/compositor/blimp_image_serialization_processor.h" |
| 17 #include "blimp/engine/app/blimp_content_browser_client.h" | 12 #include "blimp/engine/app/blimp_content_browser_client.h" |
| 18 #include "blimp/engine/app/blimp_content_renderer_client.h" | 13 #include "blimp/engine/app/blimp_content_renderer_client.h" |
| 19 #include "blimp/engine/app/blimp_engine_crash_reporter_client.h" | |
| 20 #include "components/crash/content/app/breakpad_linux.h" | |
| 21 #include "components/crash/content/app/crash_reporter_client.h" | |
| 22 #include "content/public/common/content_switches.h" | |
| 23 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 24 | 15 |
| 25 namespace blimp { | 16 namespace blimp { |
| 26 namespace engine { | 17 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 { | 18 namespace { |
| 34 void InitLogging() { | 19 void InitLogging() { |
| 35 logging::LoggingSettings settings; | 20 logging::LoggingSettings settings; |
| 36 base::FilePath log_filename; | 21 base::FilePath log_filename; |
| 37 PathService::Get(base::DIR_EXE, &log_filename); | 22 PathService::Get(base::DIR_EXE, &log_filename); |
| 38 log_filename = log_filename.AppendASCII("blimp_engine.log"); | 23 log_filename = log_filename.AppendASCII("blimp_engine.log"); |
| 39 settings.logging_dest = logging::LOG_TO_ALL; | 24 settings.logging_dest = logging::LOG_TO_ALL; |
| 40 settings.log_file = log_filename.value().c_str(); | 25 settings.log_file = log_filename.value().c_str(); |
| 41 settings.delete_old = logging::DELETE_OLD_LOG_FILE; | 26 settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
| 42 logging::InitLogging(settings); | 27 logging::InitLogging(settings); |
| 43 logging::SetLogItems(true, // Process ID | 28 logging::SetLogItems(true, // Process ID |
| 44 true, // Thread ID | 29 true, // Thread ID |
| 45 true, // Timestamp | 30 true, // Timestamp |
| 46 false); // Tick count | 31 false); // Tick count |
| 47 } | 32 } |
| 48 } // namespace | 33 } // namespace |
| 49 | 34 |
| 50 BlimpContentMainDelegate::BlimpContentMainDelegate() {} | 35 BlimpContentMainDelegate::BlimpContentMainDelegate() {} |
| 51 | 36 |
| 52 BlimpContentMainDelegate::~BlimpContentMainDelegate() {} | 37 BlimpContentMainDelegate::~BlimpContentMainDelegate() {} |
| 53 | 38 |
| 54 bool BlimpContentMainDelegate::BasicStartupComplete(int* exit_code) { | 39 bool BlimpContentMainDelegate::BasicStartupComplete(int* exit_code) { |
| 55 InitLogging(); | 40 InitLogging(); |
| 56 content::SetContentClient(&content_client_); | 41 content::SetContentClient(&content_client_); |
| 57 return false; | 42 return false; |
| 58 } | 43 } |
| 59 | 44 |
| 60 void BlimpContentMainDelegate::PreSandboxStartup() { | 45 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 const std::string process_type = | |
| 67 cmd->GetSwitchValueASCII(::switches::kProcessType); | |
| 68 cmd->AppendSwitch(::switches::kEnableCrashReporter); | |
| 69 breakpad::InitCrashReporter(process_type); | |
| 70 | |
| 71 InitializeResourceBundle(); | 46 InitializeResourceBundle(); |
| 72 } | 47 } |
| 73 | 48 |
| 74 void BlimpContentMainDelegate::InitializeResourceBundle() { | 49 void BlimpContentMainDelegate::InitializeResourceBundle() { |
| 75 base::FilePath pak_file; | 50 base::FilePath pak_file; |
| 76 bool pak_file_valid = PathService::Get(base::DIR_MODULE, &pak_file); | 51 bool pak_file_valid = PathService::Get(base::DIR_MODULE, &pak_file); |
| 77 CHECK(pak_file_valid); | 52 CHECK(pak_file_valid); |
| 78 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_engine.pak")); | 53 pak_file = pak_file.Append(FILE_PATH_LITERAL("blimp_engine.pak")); |
| 79 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | 54 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
| 80 } | 55 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 scoped_ptr<BlimpImageSerializationProcessor> image_serialization_processor = | 67 scoped_ptr<BlimpImageSerializationProcessor> image_serialization_processor = |
| 93 make_scoped_ptr(new BlimpImageSerializationProcessor( | 68 make_scoped_ptr(new BlimpImageSerializationProcessor( |
| 94 BlimpImageSerializationProcessor::Mode::SERIALIZATION)); | 69 BlimpImageSerializationProcessor::Mode::SERIALIZATION)); |
| 95 renderer_client_.reset( | 70 renderer_client_.reset( |
| 96 new BlimpContentRendererClient(std::move(image_serialization_processor))); | 71 new BlimpContentRendererClient(std::move(image_serialization_processor))); |
| 97 return renderer_client_.get(); | 72 return renderer_client_.get(); |
| 98 } | 73 } |
| 99 | 74 |
| 100 } // namespace engine | 75 } // namespace engine |
| 101 } // namespace blimp | 76 } // namespace blimp |
| OLD | NEW |