Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Side by Side Diff: mojo/services/html_viewer/html_viewer.cc

Issue 1016493002: Add a DiscardableMemoryShmemeAllocator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/logging.h" 6 #include "base/logging.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "gin/public/isolate_holder.h" 11 #include "gin/public/isolate_holder.h"
12 #include "mojo/application/application_runner_chromium.h" 12 #include "mojo/application/application_runner_chromium.h"
13 #include "mojo/services/html_viewer/html_document.h" 13 #include "mojo/services/html_viewer/html_document.h"
14 #include "mojo/services/html_viewer/html_viewer_discardable_memory_shmem_allocat or.h"
14 #include "mojo/services/html_viewer/mojo_blink_platform_impl.h" 15 #include "mojo/services/html_viewer/mojo_blink_platform_impl.h"
15 #include "mojo/services/html_viewer/webmediaplayer_factory.h" 16 #include "mojo/services/html_viewer/webmediaplayer_factory.h"
16 #include "mojo/services/network/public/interfaces/network_service.mojom.h" 17 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
17 #include "third_party/WebKit/public/web/WebKit.h" 18 #include "third_party/WebKit/public/web/WebKit.h"
18 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
19 #include "third_party/mojo/src/mojo/public/c/system/main.h" 20 #include "third_party/mojo/src/mojo/public/c/system/main.h"
20 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio n.h" 21 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio n.h"
21 #include "third_party/mojo/src/mojo/public/cpp/application/application_delegate. h" 22 #include "third_party/mojo/src/mojo/public/cpp/application/application_delegate. h"
22 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h" 23 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h"
23 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h" 24 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 class HTMLViewer : public mojo::ApplicationDelegate, 162 class HTMLViewer : public mojo::ApplicationDelegate,
162 public mojo::InterfaceFactory<ContentHandler> { 163 public mojo::InterfaceFactory<ContentHandler> {
163 public: 164 public:
164 HTMLViewer() : compositor_thread_("compositor thread") {} 165 HTMLViewer() : compositor_thread_("compositor thread") {}
165 166
166 ~HTMLViewer() override { blink::shutdown(); } 167 ~HTMLViewer() override { blink::shutdown(); }
167 168
168 private: 169 private:
169 // Overridden from ApplicationDelegate: 170 // Overridden from ApplicationDelegate:
170 void Initialize(mojo::ApplicationImpl* app) override { 171 void Initialize(mojo::ApplicationImpl* app) override {
172 base::DiscardableMemoryShmemAllocator::SetInstance(
173 &discardable_memory_allocator_);
174
171 blink_platform_.reset(new MojoBlinkPlatformImpl(app)); 175 blink_platform_.reset(new MojoBlinkPlatformImpl(app));
172 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 176 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
173 // Note: this requires file system access. 177 // Note: this requires file system access.
174 gin::IsolateHolder::LoadV8Snapshot(); 178 gin::IsolateHolder::LoadV8Snapshot();
175 #endif 179 #endif
176 blink::initialize(blink_platform_.get()); 180 blink::initialize(blink_platform_.get());
177 base::i18n::InitializeICU(); 181 base::i18n::InitializeICU();
178 182
179 ui::RegisterPathProvider(); 183 ui::RegisterPathProvider();
180 184
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 231
228 // Overridden from InterfaceFactory<ContentHandler> 232 // Overridden from InterfaceFactory<ContentHandler>
229 void Create(ApplicationConnection* connection, 233 void Create(ApplicationConnection* connection,
230 mojo::InterfaceRequest<ContentHandler> request) override { 234 mojo::InterfaceRequest<ContentHandler> request) override {
231 BindToRequest( 235 BindToRequest(
232 new ContentHandlerImpl(compositor_thread_.message_loop_proxy(), 236 new ContentHandlerImpl(compositor_thread_.message_loop_proxy(),
233 web_media_player_factory_.get(), is_headless_), 237 web_media_player_factory_.get(), is_headless_),
234 &request); 238 &request);
235 } 239 }
236 240
241 // TODO(erg): Skia requires that we have one of these. However, all the
jamesr 2015/03/16 23:47:25 what's the action item of the TODO here?
242 // fancy, non-testing versions of this look like they won't work out of the
243 // box with mojo.
244 HtmlViewerDiscardableMemoryShmemAllocator discardable_memory_allocator_;
245
237 scoped_ptr<MojoBlinkPlatformImpl> blink_platform_; 246 scoped_ptr<MojoBlinkPlatformImpl> blink_platform_;
238 base::Thread compositor_thread_; 247 base::Thread compositor_thread_;
239 scoped_ptr<WebMediaPlayerFactory> web_media_player_factory_; 248 scoped_ptr<WebMediaPlayerFactory> web_media_player_factory_;
240 // Set if the content will never be displayed. 249 // Set if the content will never be displayed.
241 bool is_headless_; 250 bool is_headless_;
242 251
243 DISALLOW_COPY_AND_ASSIGN(HTMLViewer); 252 DISALLOW_COPY_AND_ASSIGN(HTMLViewer);
244 }; 253 };
245 254
246 } // namespace html_viewer 255 } // namespace html_viewer
247 256
248 MojoResult MojoMain(MojoHandle shell_handle) { 257 MojoResult MojoMain(MojoHandle shell_handle) {
249 mojo::ApplicationRunnerChromium runner(new html_viewer::HTMLViewer); 258 mojo::ApplicationRunnerChromium runner(new html_viewer::HTMLViewer);
250 return runner.Run(shell_handle); 259 return runner.Run(shell_handle);
251 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698