| 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/client/app/blimp_startup.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/command_line.h" | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/lazy_instance.h" | |
| 12 #include "base/logging.h" | |
| 13 #include "base/message_loop/message_loop.h" | |
| 14 #include "base/path_service.h" | |
| 15 #include "blimp/client/app/blimp_discardable_memory_allocator.h" | |
| 16 #include "third_party/skia/include/core/SkGraphics.h" | |
| 17 #include "ui/base/resource/resource_bundle.h" | |
| 18 #include "ui/gl/init/gl_factory.h" | |
| 19 | |
| 20 class SkImageGenerator; | |
| 21 | |
| 22 namespace { | |
| 23 base::LazyInstance<std::unique_ptr<base::MessageLoopForUI>> | |
| 24 g_main_message_loop = LAZY_INSTANCE_INITIALIZER; | |
| 25 | |
| 26 base::LazyInstance<blimp::client::BlimpDiscardableMemoryAllocator> | |
| 27 g_discardable_memory_allocator = LAZY_INSTANCE_INITIALIZER; | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 31 namespace blimp { | |
| 32 namespace client { | |
| 33 | |
| 34 void InitializeLogging() { | |
| 35 // TODO(haibinlu): Remove this before release. | |
| 36 // Enables a few verbose log by default. | |
| 37 if (!base::CommandLine::ForCurrentProcess()->HasSwitch("vmodule")) { | |
| 38 std::string vmodule_entries = | |
| 39 "blimp_message_pump=1, blimp_connection=1," | |
| 40 "blimp_compositor=1, blimp_compositor_manager=1," | |
| 41 "remote_channel_impl=1"; | |
| 42 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII("vmodule", | |
| 43 vmodule_entries); | |
| 44 } | |
| 45 | |
| 46 logging::LoggingSettings settings; | |
| 47 #if defined(OS_ANDROID) | |
| 48 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | |
| 49 #else | |
| 50 base::FilePath log_filename; | |
| 51 PathService::Get(base::DIR_EXE, &log_filename); | |
| 52 log_filename = log_filename.AppendASCII("blimp_client.log"); | |
| 53 settings.logging_dest = logging::LOG_TO_ALL; | |
| 54 settings.log_file = log_filename.value().c_str(); | |
| 55 settings.delete_old = logging::DELETE_OLD_LOG_FILE; | |
| 56 #endif // OS_ANDROID | |
| 57 logging::InitLogging(settings); | |
| 58 logging::SetLogItems(false, // Process ID | |
| 59 false, // Thread ID | |
| 60 false, // Timestamp | |
| 61 false); // Tick count | |
| 62 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel() | |
| 63 << ", default verbosity = " << logging::GetVlogVerbosity(); | |
| 64 } | |
| 65 | |
| 66 bool InitializeMainMessageLoop() { | |
| 67 // TODO(dtrainor): Initialize ICU? | |
| 68 | |
| 69 // Set the DiscardableMemoryAllocator. | |
| 70 base::DiscardableMemoryAllocator::SetInstance( | |
| 71 g_discardable_memory_allocator.Pointer()); | |
| 72 if (!gl::init::InitializeGLOneOff()) | |
| 73 return false; | |
| 74 SkGraphics::Init(); | |
| 75 g_main_message_loop.Get().reset(new base::MessageLoopForUI); | |
| 76 return true; | |
| 77 } | |
| 78 | |
| 79 } // namespace client | |
| 80 } // namespace blimp | |
| OLD | NEW |