OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "content/child/web_memory_dump_provider_adapter.h" | |
6 | |
7 #include <stddef.h> | |
8 | |
9 #include "base/trace_event/trace_event_argument.h" | |
10 #include "content/child/web_process_memory_dump_impl.h" | |
11 #include "third_party/WebKit/public/platform/WebMemoryDumpProvider.h" | |
12 | |
13 namespace content { | |
14 | |
15 WebMemoryDumpProviderAdapter::WebMemoryDumpProviderAdapter( | |
16 blink::WebMemoryDumpProvider* wmdp) | |
17 : web_memory_dump_provider_(wmdp), is_registered_(false) { | |
18 } | |
19 | |
20 WebMemoryDumpProviderAdapter::~WebMemoryDumpProviderAdapter() { | |
21 DCHECK(!is_registered_); | |
22 } | |
23 | |
24 bool WebMemoryDumpProviderAdapter::OnMemoryDump( | |
25 const base::trace_event::MemoryDumpArgs& args, | |
26 base::trace_event::ProcessMemoryDump* pmd) { | |
27 blink::WebMemoryDumpLevelOfDetail level; | |
28 switch (args.level_of_detail) { | |
29 case base::trace_event::MemoryDumpLevelOfDetail::LIGHT: | |
30 level = blink::WebMemoryDumpLevelOfDetail::Light; | |
31 break; | |
32 case base::trace_event::MemoryDumpLevelOfDetail::DETAILED: | |
33 level = blink::WebMemoryDumpLevelOfDetail::Detailed; | |
34 break; | |
35 default: | |
36 NOTREACHED(); | |
37 return false; | |
38 } | |
39 WebProcessMemoryDumpImpl web_pmd_impl(args.level_of_detail, pmd); | |
40 return web_memory_dump_provider_->onMemoryDump(level, &web_pmd_impl); | |
41 } | |
42 | |
43 void WebMemoryDumpProviderAdapter::OnHeapProfilingEnabled(bool enabled) { | |
44 if (!web_memory_dump_provider_->supportsHeapProfiling()) | |
45 return; | |
46 web_memory_dump_provider_->onHeapProfilingEnabled(enabled); | |
47 } | |
48 | |
49 } // namespace content | |
OLD | NEW |