| 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" | |
| 33 #include "platform/PartitionAllocMemoryDumpProvider.h" | 31 #include "platform/PartitionAllocMemoryDumpProvider.h" |
| 34 #include "platform/graphics/CompositorFactory.h" | 32 #include "platform/graphics/CompositorFactory.h" |
| 35 #include "platform/web_memory_dump_provider_adapter.h" | |
| 36 #include "public/platform/Platform.h" | 33 #include "public/platform/Platform.h" |
| 37 #include "wtf/HashMap.h" | |
| 38 #include "wtf/OwnPtr.h" | |
| 39 | 34 |
| 40 namespace blink { | 35 namespace blink { |
| 41 | 36 |
| 42 static Platform* s_platform = 0; | 37 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 | |
| 54 | 38 |
| 55 Platform::Platform() | 39 Platform::Platform() |
| 56 : m_mainThread(0) | 40 : m_mainThread(0) |
| 57 { | 41 { |
| 58 } | 42 } |
| 59 | 43 |
| 60 void Platform::initialize(Platform* platform) | 44 void Platform::initialize(Platform* platform) |
| 61 { | 45 { |
| 62 s_platform = platform; | 46 s_platform = platform; |
| 63 if (s_platform) | 47 if (s_platform) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 85 Platform* Platform::current() | 69 Platform* Platform::current() |
| 86 { | 70 { |
| 87 return s_platform; | 71 return s_platform; |
| 88 } | 72 } |
| 89 | 73 |
| 90 WebThread* Platform::mainThread() const | 74 WebThread* Platform::mainThread() const |
| 91 { | 75 { |
| 92 return m_mainThread; | 76 return m_mainThread; |
| 93 } | 77 } |
| 94 | 78 |
| 95 void Platform::registerMemoryDumpProvider(WebMemoryDumpProvider* provider, const
char* name) | |
| 96 { | |
| 97 WebMemoryDumpProviderAdapter* adapter = new WebMemoryDumpProviderAdapter(pro
vider); | |
| 98 ProviderToAdapterMap::AddResult result = memoryDumpProviders().add(provider,
adoptPtr(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* provider) | |
| 106 { | |
| 107 ProviderToAdapterMap::iterator it = memoryDumpProviders().find(provider); | |
| 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 | |
| 116 } // namespace blink | 79 } // namespace blink |
| OLD | NEW |