Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: third_party/WebKit/Source/platform/exported/Platform.cpp

Issue 2043753002: Declarative resource hints go through mojo IPC to //content Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use unique_ptr to avoid memory leaks in unit tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/PlatformMojoInterface.h"
36 #include "platform/fonts/FontCacheMemoryDumpProvider.h" 37 #include "platform/fonts/FontCacheMemoryDumpProvider.h"
37 #include "platform/graphics/CompositorFactory.h" 38 #include "platform/graphics/CompositorFactory.h"
38 #include "platform/heap/BlinkGCMemoryDumpProvider.h" 39 #include "platform/heap/BlinkGCMemoryDumpProvider.h"
39 #include "platform/heap/GCTaskRunner.h" 40 #include "platform/heap/GCTaskRunner.h"
40 #include "public/platform/Platform.h" 41 #include "public/platform/Platform.h"
41 #include "public/platform/ServiceRegistry.h" 42 #include "public/platform/ServiceRegistry.h"
42 #include "public/platform/WebPrerenderingSupport.h" 43 #include "public/platform/WebPrerenderingSupport.h"
44 #include "public/platform/WebPrescientNetworking.h"
43 #include "wtf/HashMap.h" 45 #include "wtf/HashMap.h"
44 #include "wtf/OwnPtr.h" 46 #include "wtf/OwnPtr.h"
45 47
46 namespace blink { 48 namespace blink {
47 49
48 static Platform* s_platform = nullptr; 50 static Platform* s_platform = nullptr;
49 51
50 static GCTaskRunner* s_gcTaskRunner = nullptr; 52 static GCTaskRunner* s_gcTaskRunner = nullptr;
51 53
52 Platform::Platform() 54 Platform::Platform()
53 : m_mainThread(0) 55 : m_mainThread(0)
56 , m_mojoInterface(nullptr)
kinuko 2016/06/16 05:39:58 shouldn't need this
Charlie Harrison 2016/06/16 11:00:20 Done.
54 { 57 {
55 } 58 }
56 59
60 Platform::~Platform()
kinuko 2016/06/16 05:39:58 = default works?
Charlie Harrison 2016/06/16 11:00:20 Done.
61 {
62 }
63
57 static void maxObservedSizeFunction(size_t sizeInMB) 64 static void maxObservedSizeFunction(size_t sizeInMB)
58 { 65 {
59 const size_t supportedMaxSizeInMB = 4 * 1024; 66 const size_t supportedMaxSizeInMB = 4 * 1024;
60 if (sizeInMB >= supportedMaxSizeInMB) 67 if (sizeInMB >= supportedMaxSizeInMB)
61 sizeInMB = supportedMaxSizeInMB - 1; 68 sizeInMB = supportedMaxSizeInMB - 1;
62 69
63 // Send a UseCounter only when we see the highest memory usage 70 // Send a UseCounter only when we see the highest memory usage
64 // we've ever seen. 71 // we've ever seen.
65 DEFINE_STATIC_LOCAL(EnumerationHistogram, committedSizeHistogram, ("Partitio nAlloc.CommittedSize", supportedMaxSizeInMB)); 72 DEFINE_STATIC_LOCAL(EnumerationHistogram, committedSizeHistogram, ("Partitio nAlloc.CommittedSize", supportedMaxSizeInMB));
66 committedSizeHistogram.count(sizeInMB); 73 committedSizeHistogram.count(sizeInMB);
(...skipping 23 matching lines...) Expand all
90 // TODO(ssid): remove this check after fixing crbug.com/486782. 97 // TODO(ssid): remove this check after fixing crbug.com/486782.
91 if (s_platform->m_mainThread) { 98 if (s_platform->m_mainThread) {
92 ASSERT(!s_gcTaskRunner); 99 ASSERT(!s_gcTaskRunner);
93 s_gcTaskRunner = new GCTaskRunner(s_platform->m_mainThread); 100 s_gcTaskRunner = new GCTaskRunner(s_platform->m_mainThread);
94 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide r(PartitionAllocMemoryDumpProvider::instance(), "PartitionAlloc", base::ThreadTa skRunnerHandle::Get()); 101 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide r(PartitionAllocMemoryDumpProvider::instance(), "PartitionAlloc", base::ThreadTa skRunnerHandle::Get());
95 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide r(FontCacheMemoryDumpProvider::instance(), "FontCaches", base::ThreadTaskRunnerH andle::Get()); 102 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide r(FontCacheMemoryDumpProvider::instance(), "FontCaches", base::ThreadTaskRunnerH andle::Get());
96 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide r(MemoryCacheDumpProvider::instance(), "MemoryCache", base::ThreadTaskRunnerHand le::Get()); 103 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvide r(MemoryCacheDumpProvider::instance(), "MemoryCache", base::ThreadTaskRunnerHand le::Get());
97 } 104 }
98 105
99 CompositorFactory::initializeDefault(); 106 CompositorFactory::initializeDefault();
107 s_platform->m_mojoInterface.reset(new PlatformMojoInterface);
100 } 108 }
101 109
102 void Platform::shutdown() 110 void Platform::shutdown()
kinuko 2016/06/16 05:39:58 should we clear mojoInterface here?
Charlie Harrison 2016/06/16 21:31:22 Done.
103 { 111 {
104 ASSERT(isMainThread()); 112 ASSERT(isMainThread());
113
105 CompositorFactory::shutdown(); 114 CompositorFactory::shutdown();
106 115
107 if (s_platform->m_mainThread) { 116 if (s_platform->m_mainThread) {
108 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi der(FontCacheMemoryDumpProvider::instance()); 117 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi der(FontCacheMemoryDumpProvider::instance());
109 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi der(PartitionAllocMemoryDumpProvider::instance()); 118 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi der(PartitionAllocMemoryDumpProvider::instance());
110 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi der(BlinkGCMemoryDumpProvider::instance()); 119 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi der(BlinkGCMemoryDumpProvider::instance());
111 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi der(MemoryCacheDumpProvider::instance()); 120 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvi der(MemoryCacheDumpProvider::instance());
112 121
113 ASSERT(s_gcTaskRunner); 122 ASSERT(s_gcTaskRunner);
114 delete s_gcTaskRunner; 123 delete s_gcTaskRunner;
(...skipping 28 matching lines...) Expand all
143 WebThread* Platform::mainThread() const 152 WebThread* Platform::mainThread() const
144 { 153 {
145 return m_mainThread; 154 return m_mainThread;
146 } 155 }
147 156
148 ServiceRegistry* Platform::serviceRegistry() 157 ServiceRegistry* Platform::serviceRegistry()
149 { 158 {
150 return ServiceRegistry::getEmptyServiceRegistry(); 159 return ServiceRegistry::getEmptyServiceRegistry();
151 } 160 }
152 161
162 void Platform::preconnect(const KURL& url, bool credentialsFlag, int numConnecti ons)
kinuko 2016/06/16 05:39:58 Do we need to expose methods for each of these? J
Charlie Harrison 2016/06/16 11:00:20 SGTM. Done.
163 {
164 m_mojoInterface->resourceHintsHandlerHost()->Preconnect(url, credentialsFlag , numConnections);
165 }
166
167 void Platform::preresolve(const KURL& url)
168 {
169 m_mojoInterface->resourceHintsHandlerHost()->Preresolve(url);
170 }
171
172 void Platform::speculativePreresolve(const KURL& url)
173 {
174 if (WebPrescientNetworking* prescientNetworking = Platform::current()->presc ientNetworking())
175 prescientNetworking->prefetchDNS(url.host());
176 }
177
153 } // namespace blink 178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698