Chromium Code Reviews| 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 "platform/graphics/CompositorFactory.h" | 35 #include "platform/graphics/CompositorFactory.h" |
| 33 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 37 #include "wtf/HashMap.h" | |
| 38 #include "wtf/OwnPtr.h" | |
| 34 | 39 |
| 35 namespace blink { | 40 namespace blink { |
| 36 | 41 |
| 37 static Platform* s_platform = 0; | 42 static Platform* s_platform = 0; |
| 43 using ProviderToAdapterMap = HashMap<WebMemoryDumpProvider*, OwnPtr<WebMemoryDum pProviderAdapter>>; | |
| 44 | |
| 45 namespace { | |
| 46 | |
| 47 ProviderToAdapterMap& memoryDumpProviders() | |
| 48 { | |
| 49 DEFINE_STATIC_LOCAL(ProviderToAdapterMap, providerToAdapterMap, ()); | |
| 50 return providerToAdapterMap; | |
| 51 } | |
| 52 | |
| 53 } // namespace | |
| 38 | 54 |
| 39 Platform::Platform() | 55 Platform::Platform() |
| 40 : m_mainThread(0) | 56 : m_mainThread(0) |
| 41 { | 57 { |
| 42 } | 58 } |
| 43 | 59 |
| 44 void Platform::initialize(Platform* platform) | 60 void Platform::initialize(Platform* platform) |
| 45 { | 61 { |
| 46 s_platform = platform; | 62 s_platform = platform; |
| 47 if (s_platform) | 63 if (s_platform) |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 69 Platform* Platform::current() | 85 Platform* Platform::current() |
| 70 { | 86 { |
| 71 return s_platform; | 87 return s_platform; |
| 72 } | 88 } |
| 73 | 89 |
| 74 WebThread* Platform::mainThread() const | 90 WebThread* Platform::mainThread() const |
| 75 { | 91 { |
| 76 return m_mainThread; | 92 return m_mainThread; |
| 77 } | 93 } |
| 78 | 94 |
| 95 void Platform::registerMemoryDumpProvider(WebMemoryDumpProvider* wmdp, const cha r* name) | |
|
esprehn
2016/02/23 00:11:59
don't abbreviate, wmdp -> |provider|
hajimehoshi
2016/02/23 07:47:35
Done.
| |
| 96 { | |
| 97 WebMemoryDumpProviderAdapter* adapter = new WebMemoryDumpProviderAdapter(wmd p); | |
| 98 ProviderToAdapterMap::AddResult result = memoryDumpProviders().add(wmdp, ado ptPtr(adapter)); | |
| 99 if (!result.isNewEntry) | |
| 100 return; | |
| 101 adapter->set_is_registered(true); | |
| 102 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(ad apter, name, base::ThreadTaskRunnerHandle::Get()); | |
| 103 } | |
| 104 | |
| 105 void Platform::unregisterMemoryDumpProvider(WebMemoryDumpProvider* wmdp) | |
|
esprehn
2016/02/23 00:11:59
ditto
hajimehoshi
2016/02/23 07:47:35
Done.
| |
| 106 { | |
| 107 ProviderToAdapterMap::iterator it = memoryDumpProviders().find(wmdp); | |
| 108 if (it == memoryDumpProviders().end()) | |
| 109 return; | |
| 110 WebMemoryDumpProviderAdapter* adapter = it->value.get(); | |
| 111 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( adapter); | |
| 112 adapter->set_is_registered(false); | |
| 113 memoryDumpProviders().remove(it); | |
| 114 } | |
| 115 | |
| 79 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |