summaryrefslogtreecommitdiffstats
path: root/content/child/web_discardable_memory_impl.h
blob: dcde8be687f5a625f8c398f0c340010f2b1bebeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_CHILD_WEB_DISCARDABLE_MEMORY_IMPL_H_
#define CONTENT_CHILD_WEB_DISCARDABLE_MEMORY_IMPL_H_

#include <stddef.h>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/WebKit/public/platform/WebDiscardableMemory.h"

namespace base {
class DiscardableMemory;
}

namespace content {

// Implementation of WebDiscardableMemory that is responsible for allocating
// discardable memory.
class WebDiscardableMemoryImpl : public blink::WebDiscardableMemory {
 public:
  ~WebDiscardableMemoryImpl() override;

  static scoped_ptr<WebDiscardableMemoryImpl> CreateLockedMemory(size_t size);

  // blink::WebDiscardableMemory:
  bool lock() override;
  void unlock() override;
  void* data() override;
  blink::WebMemoryAllocatorDump* createMemoryAllocatorDump(
      const blink::WebString& name,
      blink::WebProcessMemoryDump* wpmd) const override;

 private:
  WebDiscardableMemoryImpl(scoped_ptr<base::DiscardableMemory> memory);

  scoped_ptr<base::DiscardableMemory> discardable_;

  DISALLOW_COPY_AND_ASSIGN(WebDiscardableMemoryImpl);
};

}  // namespace content

#endif  // CONTENT_CHILD_WEB_DISCARDABLE_MEMORY_IMPL_H_