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 13 matching lines...) Expand all Loading... | |
| 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" | 31 #include "base/thread_task_runner_handle.h" |
| 32 #include "base/trace_event/memory_dump_manager.h" | 32 #include "base/trace_event/memory_dump_manager.h" |
| 33 #include "platform/PartitionAllocMemoryDumpProvider.h" | 33 #include "platform/PartitionAllocMemoryDumpProvider.h" |
| 34 #include "platform/fonts/FontCacheMemoryDumpProvider.h" | |
| 34 #include "platform/graphics/CompositorFactory.h" | 35 #include "platform/graphics/CompositorFactory.h" |
| 35 #include "platform/web_memory_dump_provider_adapter.h" | 36 #include "platform/web_memory_dump_provider_adapter.h" |
| 36 #include "public/platform/Platform.h" | 37 #include "public/platform/Platform.h" |
| 37 #include "wtf/HashMap.h" | 38 #include "wtf/HashMap.h" |
| 38 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 static Platform* s_platform = 0; | 43 static Platform* s_platform = 0; |
| 43 using ProviderToAdapterMap = HashMap<WebMemoryDumpProvider*, OwnPtr<WebMemoryDum pProviderAdapter>>; | 44 using ProviderToAdapterMap = HashMap<WebMemoryDumpProvider*, OwnPtr<WebMemoryDum pProviderAdapter>>; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 61 { | 62 { |
| 62 s_platform = platform; | 63 s_platform = platform; |
| 63 if (s_platform) | 64 if (s_platform) |
| 64 s_platform->m_mainThread = platform->currentThread(); | 65 s_platform->m_mainThread = platform->currentThread(); |
| 65 | 66 |
| 66 // TODO(ssid): remove this check after fixing crbug.com/486782. | 67 // TODO(ssid): remove this check after fixing crbug.com/486782. |
| 67 if (s_platform && s_platform->m_mainThread) | 68 if (s_platform && s_platform->m_mainThread) |
| 68 s_platform->registerMemoryDumpProvider(PartitionAllocMemoryDumpProvider: :instance(), "PartitionAlloc"); | 69 s_platform->registerMemoryDumpProvider(PartitionAllocMemoryDumpProvider: :instance(), "PartitionAlloc"); |
| 69 | 70 |
| 70 CompositorFactory::initializeDefault(); | 71 CompositorFactory::initializeDefault(); |
| 72 platform->registerMemoryDumpProvider(FontCacheMemoryDumpProvider::instance() , "FontCaches"); | |
|
sof
2016/03/10 07:40:12
So what is the status of |platform|, can it be non
| |
| 71 } | 73 } |
| 72 | 74 |
| 73 void Platform::shutdown() | 75 void Platform::shutdown() |
| 74 { | 76 { |
| 77 s_platform->unregisterMemoryDumpProvider(FontCacheMemoryDumpProvider::instan ce()); | |
| 75 CompositorFactory::shutdown(); | 78 CompositorFactory::shutdown(); |
| 76 | 79 |
| 77 if (s_platform->m_mainThread) | 80 if (s_platform->m_mainThread) |
| 78 s_platform->unregisterMemoryDumpProvider(PartitionAllocMemoryDumpProvide r::instance()); | 81 s_platform->unregisterMemoryDumpProvider(PartitionAllocMemoryDumpProvide r::instance()); |
| 79 | 82 |
| 80 if (s_platform) | 83 if (s_platform) |
| 81 s_platform->m_mainThread = 0; | 84 s_platform->m_mainThread = 0; |
| 82 s_platform = 0; | 85 s_platform = 0; |
| 83 } | 86 } |
| 84 | 87 |
| 85 Platform* Platform::current() | 88 Platform* Platform::current() |
| 86 { | 89 { |
| 87 return s_platform; | 90 return s_platform; |
| 88 } | 91 } |
| 89 | 92 |
| 90 WebThread* Platform::mainThread() const | 93 WebThread* Platform::mainThread() const |
| 91 { | 94 { |
| 92 return m_mainThread; | 95 return m_mainThread; |
| 93 } | 96 } |
| 94 | 97 |
| 95 void Platform::registerMemoryDumpProvider(WebMemoryDumpProvider* provider, const char* name) | 98 void Platform::registerMemoryDumpProvider(WebMemoryDumpProvider* provider, const char* name) |
| 96 { | 99 { |
| 100 // MemoryDumpProvider needs a message loop. | |
| 101 if (!Platform::current()->currentThread()) | |
| 102 return; | |
| 103 | |
| 97 WebMemoryDumpProviderAdapter* adapter = new WebMemoryDumpProviderAdapter(pro vider); | 104 WebMemoryDumpProviderAdapter* adapter = new WebMemoryDumpProviderAdapter(pro vider); |
| 98 ProviderToAdapterMap::AddResult result = memoryDumpProviders().add(provider, adoptPtr(adapter)); | 105 ProviderToAdapterMap::AddResult result = memoryDumpProviders().add(provider, adoptPtr(adapter)); |
| 99 if (!result.isNewEntry) | 106 if (!result.isNewEntry) |
| 100 return; | 107 return; |
| 101 adapter->set_is_registered(true); | 108 adapter->set_is_registered(true); |
| 102 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(ad apter, name, base::ThreadTaskRunnerHandle::Get()); | 109 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(ad apter, name, base::ThreadTaskRunnerHandle::Get()); |
| 103 } | 110 } |
| 104 | 111 |
| 105 void Platform::unregisterMemoryDumpProvider(WebMemoryDumpProvider* provider) | 112 void Platform::unregisterMemoryDumpProvider(WebMemoryDumpProvider* provider) |
| 106 { | 113 { |
| 114 // MemoryDumpProvider needs a message loop. | |
| 115 if (!Platform::current()->currentThread()) | |
| 116 return; | |
| 117 | |
| 107 ProviderToAdapterMap::iterator it = memoryDumpProviders().find(provider); | 118 ProviderToAdapterMap::iterator it = memoryDumpProviders().find(provider); |
| 108 if (it == memoryDumpProviders().end()) | 119 if (it == memoryDumpProviders().end()) |
| 109 return; | 120 return; |
| 110 WebMemoryDumpProviderAdapter* adapter = it->value.get(); | 121 WebMemoryDumpProviderAdapter* adapter = it->value.get(); |
| 111 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( adapter); | 122 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( adapter); |
| 112 adapter->set_is_registered(false); | 123 adapter->set_is_registered(false); |
| 113 memoryDumpProviders().remove(it); | 124 memoryDumpProviders().remove(it); |
| 114 } | 125 } |
| 115 | 126 |
| 116 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |