Chromium Code Reviews| Index: mojo/services/html_viewer/html_viewer.cc |
| diff --git a/mojo/services/html_viewer/html_viewer.cc b/mojo/services/html_viewer/html_viewer.cc |
| index 8c71a9f3ab55ab08188141b4208174ff49dc615b..32621ac3c212f4f95dcc36de5fb7488629577c25 100644 |
| --- a/mojo/services/html_viewer/html_viewer.cc |
| +++ b/mojo/services/html_viewer/html_viewer.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/threading/thread.h" |
| #include "gin/public/isolate_holder.h" |
| #include "mojo/application/application_runner_chromium.h" |
| +#include "mojo/services/html_viewer/discardable_memory_allocator.h" |
| #include "mojo/services/html_viewer/html_document.h" |
| #include "mojo/services/html_viewer/mojo_blink_platform_impl.h" |
| #include "mojo/services/html_viewer/webmediaplayer_factory.h" |
| @@ -59,6 +60,9 @@ const char kDisableEncryptedMedia[] = "disable-encrypted-media"; |
| // Prevents creation of any output surface. |
| const char kIsHeadless[] = "is-headless"; |
| +// Only have 20 megabytes of discardable memory to start out with. |
|
jamesr
2015/03/18 22:40:14
what do you mean "to start out with"? it doesn't s
|
| +size_t kMaxMemory = 20 * 1024 * 1024; |
|
jamesr
2015/03/18 22:40:14
if i'm reading the allocator correctly the first a
Elliot Glaysher
2015/03/18 23:54:44
Renamed to 'kDesiredMaxMemory', and moved the abov
|
| + |
| class HTMLViewer; |
| class HTMLViewerApplication : public mojo::Application { |
| @@ -161,13 +165,18 @@ class ContentHandlerImpl : public mojo::InterfaceImpl<ContentHandler> { |
| class HTMLViewer : public mojo::ApplicationDelegate, |
| public mojo::InterfaceFactory<ContentHandler> { |
| public: |
| - HTMLViewer() : compositor_thread_("compositor thread") {} |
| + HTMLViewer() |
| + : discardable_memory_allocator_(kMaxMemory), |
| + compositor_thread_("compositor thread") {} |
| ~HTMLViewer() override { blink::shutdown(); } |
| private: |
| // Overridden from ApplicationDelegate: |
| void Initialize(mojo::ApplicationImpl* app) override { |
| + base::DiscardableMemoryAllocator::SetInstance( |
| + &discardable_memory_allocator_); |
| + |
| blink_platform_.reset(new MojoBlinkPlatformImpl(app)); |
| #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| // Note: this requires file system access. |
| @@ -234,6 +243,14 @@ class HTMLViewer : public mojo::ApplicationDelegate, |
| &request); |
| } |
| + // Skia requires that we have one of these. Unlike the one used in chrome, |
| + // this doesn't use purgable shared memory. Instead, it tries to free the |
| + // oldest unlocked chunks on allocation. |
| + // |
| + // TODO(erg): In the long run, delete this allocator and get the real shared |
| + // memory based purging allocator working here. |
| + DiscardableMemoryAllocator discardable_memory_allocator_; |
| + |
| scoped_ptr<MojoBlinkPlatformImpl> blink_platform_; |
| base::Thread compositor_thread_; |
| scoped_ptr<WebMediaPlayerFactory> web_media_player_factory_; |