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

Unified 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: jamesr comments + rebase to ToT 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/services/html_viewer/discardable_memory_allocator_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1391c1c7372f501971e944e68dc8913ac67031c2 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,8 @@ const char kDisableEncryptedMedia[] = "disable-encrypted-media";
// Prevents creation of any output surface.
const char kIsHeadless[] = "is-headless";
+size_t kDesiredMaxMemory = 20 * 1024 * 1024;
+
class HTMLViewer;
class HTMLViewerApplication : public mojo::Application {
@@ -161,13 +164,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_(kDesiredMaxMemory),
+ 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 +242,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_;
« no previous file with comments | « mojo/services/html_viewer/discardable_memory_allocator_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698