| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/child/web_discardable_memory_impl.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/memory/discardable_memory.h" | |
| 10 #include "base/memory/discardable_memory_allocator.h" | |
| 11 #include "third_party/WebKit/public/platform/WebProcessMemoryDump.h" | |
| 12 #include "third_party/WebKit/public/platform/WebString.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 WebDiscardableMemoryImpl::~WebDiscardableMemoryImpl() {} | |
| 17 | |
| 18 // static | |
| 19 scoped_ptr<WebDiscardableMemoryImpl> | |
| 20 WebDiscardableMemoryImpl::CreateLockedMemory(size_t size) { | |
| 21 return make_scoped_ptr(new WebDiscardableMemoryImpl( | |
| 22 base::DiscardableMemoryAllocator::GetInstance() | |
| 23 ->AllocateLockedDiscardableMemory(size))); | |
| 24 } | |
| 25 | |
| 26 bool WebDiscardableMemoryImpl::lock() { | |
| 27 return discardable_->Lock(); | |
| 28 } | |
| 29 | |
| 30 void WebDiscardableMemoryImpl::unlock() { | |
| 31 discardable_->Unlock(); | |
| 32 } | |
| 33 | |
| 34 void* WebDiscardableMemoryImpl::data() { | |
| 35 return discardable_->data(); | |
| 36 } | |
| 37 | |
| 38 blink::WebMemoryAllocatorDump* | |
| 39 WebDiscardableMemoryImpl::createMemoryAllocatorDump( | |
| 40 const blink::WebString& name, | |
| 41 blink::WebProcessMemoryDump* wpmd) const { | |
| 42 return wpmd->createDiscardableMemoryAllocatorDump( | |
| 43 name.utf8(), discardable_.get()); | |
| 44 } | |
| 45 | |
| 46 WebDiscardableMemoryImpl::WebDiscardableMemoryImpl( | |
| 47 scoped_ptr<base::DiscardableMemory> memory) | |
| 48 : discardable_(std::move(memory)) {} | |
| 49 | |
| 50 } // namespace content | |
| OLD | NEW |