1 // Copyright 2015 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.
5 #ifndef CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_
6 #define CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_
8 #include "base/gtest_prod_util.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "content/common/content_export.h"
12 #include "third_party/WebKit/public/platform/WebProcessMemoryDump.h"
15 namespace trace_event
{
16 class ProcessMemoryDump
;
18 } // namespace trace_event
22 class WebMemoryAllocatorDumpImpl
;
24 // Implements the blink::WebProcessMemoryDump interface by means of proxying the
25 // calls to createMemoryAllocatorDump() to the underlying
26 // base::trace_event::ProcessMemoryDump instance.
27 class CONTENT_EXPORT WebProcessMemoryDumpImpl final
28 : public NON_EXPORTED_BASE(blink::WebProcessMemoryDump
) {
30 // Creates a standalone WebProcessMemoryDumpImp, which owns the underlying
32 WebProcessMemoryDumpImpl();
34 // Wraps (without owning) an existing ProcessMemoryDump.
35 explicit WebProcessMemoryDumpImpl(
36 base::trace_event::ProcessMemoryDump
* process_memory_dump
);
38 virtual ~WebProcessMemoryDumpImpl();
40 // blink::WebProcessMemoryDump implementation.
41 virtual blink::WebMemoryAllocatorDump
* createMemoryAllocatorDump(
42 const blink::WebString
& absolute_name
);
43 virtual void takeAllDumpsFrom(blink::WebProcessMemoryDump
* other
);
45 const base::trace_event::ProcessMemoryDump
* process_memory_dump() const {
46 return process_memory_dump_
;
50 FRIEND_TEST_ALL_PREFIXES(WebProcessMemoryDumpImplTest
, IntegrationTest
);
52 // Only for the case of ProcessMemoryDump being owned (i.e. the default ctor).
53 scoped_ptr
<base::trace_event::ProcessMemoryDump
> owned_process_memory_dump_
;
55 // The underlying ProcessMemoryDump instance to which the
56 // createMemoryAllocatorDump() calls will be proxied to.
57 base::trace_event::ProcessMemoryDump
* process_memory_dump_
; // Not owned.
59 // By design WebMemoryDumpProvider(s) are not supposed to hold the pointer
60 // to the WebProcessMemoryDump passed as argument of the onMemoryDump() call.
61 // Those pointers are valid only within the scope of the call and can be
62 // safely torn down once the WebProcessMemoryDumpImpl itself is destroyed.
63 ScopedVector
<WebMemoryAllocatorDumpImpl
> memory_allocator_dumps_
;
65 DISALLOW_COPY_AND_ASSIGN(WebProcessMemoryDumpImpl
);
68 } // namespace content
70 #endif // CONTENT_CHILD_WEB_PROCESS_MEMORY_DUMP_IMPL_H_