| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/i18n/icu_util.h" | 6 #include "base/i18n/icu_util.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "components/html_viewer/blink_platform_impl.h" | 13 #include "components/html_viewer/blink_platform_impl.h" |
| 14 #include "components/html_viewer/discardable_memory_allocator.h" | 14 #include "components/html_viewer/discardable_memory_allocator.h" |
| 15 #include "components/html_viewer/html_document.h" | 15 #include "components/html_viewer/html_document.h" |
| 16 #include "components/html_viewer/web_media_player_factory.h" | 16 #include "components/html_viewer/web_media_player_factory.h" |
| 17 #include "components/scheduler/renderer/renderer_scheduler.h" |
| 17 #include "gin/v8_initializer.h" | 18 #include "gin/v8_initializer.h" |
| 18 #include "mojo/application/application_runner_chromium.h" | 19 #include "mojo/application/application_runner_chromium.h" |
| 19 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 20 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 20 #include "third_party/WebKit/public/web/WebKit.h" | 21 #include "third_party/WebKit/public/web/WebKit.h" |
| 21 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 22 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 22 #include "third_party/mojo/src/mojo/public/c/system/main.h" | 23 #include "third_party/mojo/src/mojo/public/c/system/main.h" |
| 23 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio
n.h" | 24 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio
n.h" |
| 24 #include "third_party/mojo/src/mojo/public/cpp/application/application_delegate.
h" | 25 #include "third_party/mojo/src/mojo/public/cpp/application/application_delegate.
h" |
| 25 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h" | 26 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h" |
| 26 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h" | 27 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 compositor_thread_("compositor thread") {} | 166 compositor_thread_("compositor thread") {} |
| 166 | 167 |
| 167 ~HTMLViewer() override { blink::shutdown(); } | 168 ~HTMLViewer() override { blink::shutdown(); } |
| 168 | 169 |
| 169 private: | 170 private: |
| 170 // Overridden from ApplicationDelegate: | 171 // Overridden from ApplicationDelegate: |
| 171 void Initialize(mojo::ApplicationImpl* app) override { | 172 void Initialize(mojo::ApplicationImpl* app) override { |
| 172 base::DiscardableMemoryAllocator::SetInstance( | 173 base::DiscardableMemoryAllocator::SetInstance( |
| 173 &discardable_memory_allocator_); | 174 &discardable_memory_allocator_); |
| 174 | 175 |
| 175 blink_platform_.reset(new BlinkPlatformImpl(app)); | 176 renderer_scheduler_ = scheduler::RendererScheduler::Create(); |
| 177 blink_platform_.reset( |
| 178 new BlinkPlatformImpl(app, renderer_scheduler_.get())); |
| 176 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 179 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 177 // Note: this requires file system access. | 180 // Note: this requires file system access. |
| 178 gin::V8Initializer::LoadV8Snapshot(); | 181 gin::V8Initializer::LoadV8Snapshot(); |
| 179 #endif | 182 #endif |
| 180 blink::initialize(blink_platform_.get()); | 183 blink::initialize(blink_platform_.get()); |
| 181 base::i18n::InitializeICU(); | 184 base::i18n::InitializeICU(); |
| 182 | 185 |
| 183 ui::RegisterPathProvider(); | 186 ui::RegisterPathProvider(); |
| 184 | 187 |
| 185 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 188 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 233 } |
| 231 | 234 |
| 232 // Skia requires that we have one of these. Unlike the one used in chrome, | 235 // Skia requires that we have one of these. Unlike the one used in chrome, |
| 233 // this doesn't use purgable shared memory. Instead, it tries to free the | 236 // this doesn't use purgable shared memory. Instead, it tries to free the |
| 234 // oldest unlocked chunks on allocation. | 237 // oldest unlocked chunks on allocation. |
| 235 // | 238 // |
| 236 // TODO(erg): In the long run, delete this allocator and get the real shared | 239 // TODO(erg): In the long run, delete this allocator and get the real shared |
| 237 // memory based purging allocator working here. | 240 // memory based purging allocator working here. |
| 238 DiscardableMemoryAllocator discardable_memory_allocator_; | 241 DiscardableMemoryAllocator discardable_memory_allocator_; |
| 239 | 242 |
| 243 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler_; |
| 240 scoped_ptr<BlinkPlatformImpl> blink_platform_; | 244 scoped_ptr<BlinkPlatformImpl> blink_platform_; |
| 241 base::Thread compositor_thread_; | 245 base::Thread compositor_thread_; |
| 242 scoped_ptr<WebMediaPlayerFactory> web_media_player_factory_; | 246 scoped_ptr<WebMediaPlayerFactory> web_media_player_factory_; |
| 243 // Set if the content will never be displayed. | 247 // Set if the content will never be displayed. |
| 244 bool is_headless_; | 248 bool is_headless_; |
| 245 | 249 |
| 246 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); | 250 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); |
| 247 }; | 251 }; |
| 248 | 252 |
| 249 } // namespace html_viewer | 253 } // namespace html_viewer |
| 250 | 254 |
| 251 MojoResult MojoMain(MojoHandle shell_handle) { | 255 MojoResult MojoMain(MojoHandle shell_handle) { |
| 252 mojo::ApplicationRunnerChromium runner(new html_viewer::HTMLViewer); | 256 mojo::ApplicationRunnerChromium runner(new html_viewer::HTMLViewer); |
| 253 return runner.Run(shell_handle); | 257 return runner.Run(shell_handle); |
| 254 } | 258 } |
| OLD | NEW |