提交 693dd482 编写于 作者: A Adam Barth

Call DiscardableMemoryAllocator::SetInstance()

Apparently this can cause a crash when when we try to render an emoji at a
different size than the emoji font's native bitmap size. I'm not sure how to
reproduce the issue. I'll ask Hixie when he gets back.

Currently we just use regular memory. In the future, we should actually use
discarable memory.

Fixes #203
上级 c5dca7ba
......@@ -6,6 +6,9 @@
#include "base/bind.h"
#include "base/i18n/icu_util.h"
#include "base/lazy_instance.h"
#include "base/memory/discardable_memory.h"
#include "base/memory/discardable_memory_allocator.h"
#include "base/single_thread_task_runner.h"
#include "mojo/common/message_pump_mojo.h"
#include "mojo/edk/embedder/embedder.h"
......@@ -23,6 +26,27 @@ scoped_ptr<base::MessagePump> CreateMessagePumpMojo() {
return make_scoped_ptr(new mojo::common::MessagePumpMojo);
}
class NonDiscardableMemory : public base::DiscardableMemory {
public:
explicit NonDiscardableMemory(size_t size) : data_(new uint8_t[size]) {}
bool Lock() override { return false; }
void Unlock() override {}
void* data() const override { return data_.get(); }
private:
scoped_ptr<uint8_t[]> data_;
};
class NonDiscardableMemoryAllocator : public base::DiscardableMemoryAllocator {
public:
scoped_ptr<base::DiscardableMemory> AllocateLockedDiscardableMemory(
size_t size) override {
return make_scoped_ptr(new NonDiscardableMemory(size));
}
};
base::LazyInstance<NonDiscardableMemoryAllocator> g_discardable;
} // namespace
Shell::Shell(scoped_ptr<ServiceProviderContext> service_provider_context)
......@@ -51,6 +75,8 @@ void Shell::Init(scoped_ptr<ServiceProviderContext> service_provider_context) {
#if !defined(OS_LINUX)
CHECK(gfx::GLSurface::InitializeOneOff());
#endif
base::DiscardableMemoryAllocator::SetInstance(&g_discardable.Get());
g_shell = new Shell(service_provider_context.Pass());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册