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 15 matching lines...) Expand all Loading... |
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/threading/thread_task_runner_handle.h" | 31 #include "base/threading/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/Histogram.h" | 33 #include "platform/Histogram.h" |
34 #include "platform/MemoryCacheDumpProvider.h" | 34 #include "platform/MemoryCacheDumpProvider.h" |
35 #include "platform/PartitionAllocMemoryDumpProvider.h" | 35 #include "platform/PartitionAllocMemoryDumpProvider.h" |
| 36 #include "platform/PlatformMojoServices.h" |
36 #include "platform/fonts/FontCacheMemoryDumpProvider.h" | 37 #include "platform/fonts/FontCacheMemoryDumpProvider.h" |
37 #include "platform/heap/BlinkGCMemoryDumpProvider.h" | 38 #include "platform/heap/BlinkGCMemoryDumpProvider.h" |
38 #include "platform/heap/GCTaskRunner.h" | 39 #include "platform/heap/GCTaskRunner.h" |
39 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
40 #include "public/platform/ServiceRegistry.h" | 41 #include "public/platform/ServiceRegistry.h" |
41 #include "public/platform/WebPrerenderingSupport.h" | 42 #include "public/platform/WebPrerenderingSupport.h" |
| 43 #include "public/platform/WebPrescientNetworking.h" |
42 #include "wtf/HashMap.h" | 44 #include "wtf/HashMap.h" |
43 #include "wtf/OwnPtr.h" | 45 #include "wtf/OwnPtr.h" |
44 | 46 |
45 namespace blink { | 47 namespace blink { |
46 | 48 |
47 static Platform* s_platform = nullptr; | 49 static Platform* s_platform = nullptr; |
48 | 50 |
49 static GCTaskRunner* s_gcTaskRunner = nullptr; | 51 static GCTaskRunner* s_gcTaskRunner = nullptr; |
50 | 52 |
51 Platform::Platform() | 53 Platform::Platform() |
52 : m_mainThread(0) | 54 : m_mainThread(0) |
53 { | 55 { |
54 } | 56 } |
55 | 57 |
| 58 Platform::~Platform() = default; |
| 59 |
56 static void maxObservedSizeFunction(size_t sizeInMB) | 60 static void maxObservedSizeFunction(size_t sizeInMB) |
57 { | 61 { |
58 const size_t supportedMaxSizeInMB = 4 * 1024; | 62 const size_t supportedMaxSizeInMB = 4 * 1024; |
59 if (sizeInMB >= supportedMaxSizeInMB) | 63 if (sizeInMB >= supportedMaxSizeInMB) |
60 sizeInMB = supportedMaxSizeInMB - 1; | 64 sizeInMB = supportedMaxSizeInMB - 1; |
61 | 65 |
62 // Send a UseCounter only when we see the highest memory usage | 66 // Send a UseCounter only when we see the highest memory usage |
63 // we've ever seen. | 67 // we've ever seen. |
64 DEFINE_STATIC_LOCAL(EnumerationHistogram, committedSizeHistogram, ("Partitio
nAlloc.CommittedSize", supportedMaxSizeInMB)); | 68 DEFINE_STATIC_LOCAL(EnumerationHistogram, committedSizeHistogram, ("Partitio
nAlloc.CommittedSize", supportedMaxSizeInMB)); |
65 committedSizeHistogram.count(sizeInMB); | 69 committedSizeHistogram.count(sizeInMB); |
(...skipping 21 matching lines...) Expand all Loading... |
87 ThreadState::attachMainThread(); | 91 ThreadState::attachMainThread(); |
88 | 92 |
89 // TODO(ssid): remove this check after fixing crbug.com/486782. | 93 // TODO(ssid): remove this check after fixing crbug.com/486782. |
90 if (s_platform->m_mainThread) { | 94 if (s_platform->m_mainThread) { |
91 ASSERT(!s_gcTaskRunner); | 95 ASSERT(!s_gcTaskRunner); |
92 s_gcTaskRunner = new GCTaskRunner(s_platform->m_mainThread); | 96 s_gcTaskRunner = new GCTaskRunner(s_platform->m_mainThread); |
93 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide
r(PartitionAllocMemoryDumpProvider::instance(), "PartitionAlloc", base::ThreadTa
skRunnerHandle::Get()); | 97 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide
r(PartitionAllocMemoryDumpProvider::instance(), "PartitionAlloc", base::ThreadTa
skRunnerHandle::Get()); |
94 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide
r(FontCacheMemoryDumpProvider::instance(), "FontCaches", base::ThreadTaskRunnerH
andle::Get()); | 98 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide
r(FontCacheMemoryDumpProvider::instance(), "FontCaches", base::ThreadTaskRunnerH
andle::Get()); |
95 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide
r(MemoryCacheDumpProvider::instance(), "MemoryCache", base::ThreadTaskRunnerHand
le::Get()); | 99 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide
r(MemoryCacheDumpProvider::instance(), "MemoryCache", base::ThreadTaskRunnerHand
le::Get()); |
96 } | 100 } |
| 101 s_platform->m_mojoServices.reset(new PlatformMojoServices); |
97 } | 102 } |
98 | 103 |
99 void Platform::shutdown() | 104 void Platform::shutdown() |
100 { | 105 { |
101 ASSERT(isMainThread()); | 106 ASSERT(isMainThread()); |
| 107 s_platform->m_mojoServices.reset(); |
102 if (s_platform->m_mainThread) { | 108 if (s_platform->m_mainThread) { |
103 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi
der(FontCacheMemoryDumpProvider::instance()); | 109 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi
der(FontCacheMemoryDumpProvider::instance()); |
104 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi
der(PartitionAllocMemoryDumpProvider::instance()); | 110 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi
der(PartitionAllocMemoryDumpProvider::instance()); |
105 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi
der(BlinkGCMemoryDumpProvider::instance()); | 111 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi
der(BlinkGCMemoryDumpProvider::instance()); |
106 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi
der(MemoryCacheDumpProvider::instance()); | 112 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi
der(MemoryCacheDumpProvider::instance()); |
107 | 113 |
108 ASSERT(s_gcTaskRunner); | 114 ASSERT(s_gcTaskRunner); |
109 delete s_gcTaskRunner; | 115 delete s_gcTaskRunner; |
110 s_gcTaskRunner = nullptr; | 116 s_gcTaskRunner = nullptr; |
111 } | 117 } |
(...skipping 26 matching lines...) Expand all Loading... |
138 WebThread* Platform::mainThread() const | 144 WebThread* Platform::mainThread() const |
139 { | 145 { |
140 return m_mainThread; | 146 return m_mainThread; |
141 } | 147 } |
142 | 148 |
143 ServiceRegistry* Platform::serviceRegistry() | 149 ServiceRegistry* Platform::serviceRegistry() |
144 { | 150 { |
145 return ServiceRegistry::getEmptyServiceRegistry(); | 151 return ServiceRegistry::getEmptyServiceRegistry(); |
146 } | 152 } |
147 | 153 |
| 154 PlatformMojoServices* Platform::mojoServices() |
| 155 { |
| 156 return m_mojoServices.get(); |
| 157 } |
| 158 |
148 } // namespace blink | 159 } // namespace blink |
OLD | NEW |