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 "components/html_viewer/setup.h" | 5 #include "components/html_viewer/setup.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 Setup::Setup(mojo::ApplicationImpl* app) | 68 Setup::Setup(mojo::ApplicationImpl* app) |
69 : app_(app), | 69 : app_(app), |
70 resource_loader_(app->shell(), GetResourcePaths()), | 70 resource_loader_(app->shell(), GetResourcePaths()), |
71 is_headless_( | 71 is_headless_( |
72 base::CommandLine::ForCurrentProcess()->HasSwitch(kIsHeadless)), | 72 base::CommandLine::ForCurrentProcess()->HasSwitch(kIsHeadless)), |
73 did_init_(false), | 73 did_init_(false), |
74 device_pixel_ratio_(1.f), | 74 device_pixel_ratio_(1.f), |
75 discardable_memory_allocator_(kDesiredMaxMemory), | 75 discardable_memory_allocator_(kDesiredMaxMemory), |
76 compositor_thread_("compositor thread") { | 76 compositor_thread_("compositor thread") { |
77 if (is_headless_) | 77 if (is_headless_) |
78 InitHeadless(); | 78 InitIfNecessary(gfx::Size(1024, 1024), 1.f); |
79 } | 79 } |
80 | 80 |
81 Setup::~Setup() { | 81 Setup::~Setup() { |
82 if (blink_platform_) { | 82 if (blink_platform_) { |
83 renderer_scheduler_->Shutdown(); | 83 renderer_scheduler_->Shutdown(); |
84 blink::shutdown(); | 84 blink::shutdown(); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 void Setup::InitHeadless() { | |
89 DCHECK(!did_init_); | |
90 is_headless_ = true; | |
91 InitIfNecessary(gfx::Size(1024, 1024), 1.f); | |
92 } | |
93 | |
94 void Setup::InitIfNecessary(const gfx::Size& screen_size_in_pixels, | 88 void Setup::InitIfNecessary(const gfx::Size& screen_size_in_pixels, |
95 float device_pixel_ratio) { | 89 float device_pixel_ratio) { |
96 if (did_init_) | 90 if (did_init_) |
97 return; | 91 return; |
98 | 92 |
99 DCHECK_NE(0.f, device_pixel_ratio); | 93 DCHECK_NE(0.f, device_pixel_ratio); |
100 | 94 |
101 did_init_ = true; | 95 did_init_ = true; |
102 device_pixel_ratio_ = device_pixel_ratio; | 96 device_pixel_ratio_ = device_pixel_ratio; |
103 screen_size_in_pixels_ = screen_size_in_pixels; | 97 screen_size_in_pixels_ = screen_size_in_pixels; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 media_factory_.reset( | 147 media_factory_.reset( |
154 new MediaFactory(compositor_thread_.message_loop_proxy(), app_->shell())); | 148 new MediaFactory(compositor_thread_.message_loop_proxy(), app_->shell())); |
155 | 149 |
156 if (command_line->HasSwitch(kJavaScriptFlags)) { | 150 if (command_line->HasSwitch(kJavaScriptFlags)) { |
157 std::string flags(command_line->GetSwitchValueASCII(kJavaScriptFlags)); | 151 std::string flags(command_line->GetSwitchValueASCII(kJavaScriptFlags)); |
158 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | 152 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); |
159 } | 153 } |
160 } | 154 } |
161 | 155 |
162 } // namespace html_viewer | 156 } // namespace html_viewer |
OLD | NEW |