OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 10 matching lines...) Expand all Loading... |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
| 31 #include "base/thread_task_runner_handle.h" |
| 32 #include "base/trace_event/memory_dump_manager.h" |
31 #include "platform/PartitionAllocMemoryDumpProvider.h" | 33 #include "platform/PartitionAllocMemoryDumpProvider.h" |
| 34 #include "platform/WebMemoryDumpProviderAdapter.h" |
32 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
| 36 #include "wtf/HashMap.h" |
| 37 #include "wtf/OwnPtr.h" |
33 | 38 |
34 namespace blink { | 39 namespace blink { |
35 | 40 |
36 static Platform* s_platform = 0; | 41 static Platform* s_platform = 0; |
| 42 using ProviderToAdapterMap = HashMap<WebMemoryDumpProvider*, OwnPtr<WebMemoryDum
pProviderAdapter>>; |
| 43 |
| 44 namespace { |
| 45 |
| 46 ProviderToAdapterMap& memoryDumpProviders() |
| 47 { |
| 48 DEFINE_STATIC_LOCAL(ProviderToAdapterMap, providerToAdapterMap, ()); |
| 49 return providerToAdapterMap; |
| 50 } |
| 51 |
| 52 } // namespace |
37 | 53 |
38 Platform::Platform() | 54 Platform::Platform() |
39 : m_mainThread(0) | 55 : m_mainThread(0) |
40 { | 56 { |
41 } | 57 } |
42 | 58 |
43 void Platform::initialize(Platform* platform) | 59 void Platform::initialize(Platform* platform) |
44 { | 60 { |
45 s_platform = platform; | 61 s_platform = platform; |
46 if (s_platform) | 62 if (s_platform) |
(...skipping 17 matching lines...) Expand all Loading... |
64 Platform* Platform::current() | 80 Platform* Platform::current() |
65 { | 81 { |
66 return s_platform; | 82 return s_platform; |
67 } | 83 } |
68 | 84 |
69 WebThread* Platform::mainThread() const | 85 WebThread* Platform::mainThread() const |
70 { | 86 { |
71 return m_mainThread; | 87 return m_mainThread; |
72 } | 88 } |
73 | 89 |
| 90 void Platform::registerMemoryDumpProvider(WebMemoryDumpProvider* wmdp, const cha
r* name) |
| 91 { |
| 92 WebMemoryDumpProviderAdapter* adapter = new WebMemoryDumpProviderAdapter(wmd
p); |
| 93 ProviderToAdapterMap::AddResult result = memoryDumpProviders().add(wmdp, ado
ptPtr(adapter)); |
| 94 if (!result.isNewEntry) |
| 95 return; |
| 96 adapter->set_is_registered(true); |
| 97 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(ad
apter, name, base::ThreadTaskRunnerHandle::Get()); |
| 98 } |
| 99 |
| 100 void Platform::unregisterMemoryDumpProvider(WebMemoryDumpProvider* wmdp) |
| 101 { |
| 102 ProviderToAdapterMap::iterator it = memoryDumpProviders().find(wmdp); |
| 103 if (it == memoryDumpProviders().end()) |
| 104 return; |
| 105 WebMemoryDumpProviderAdapter* adapter = it->value.get(); |
| 106 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
adapter); |
| 107 adapter->set_is_registered(false); |
| 108 memoryDumpProviders().remove(it); |
| 109 } |
| 110 |
74 } // namespace blink | 111 } // namespace blink |
OLD | NEW |