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

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

Issue 2775483003: Use public Service Manager Connector API in Blink (Closed)
Patch Set: . Created 3 years, 8 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 12 matching lines...) Expand all
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 "public/platform/Platform.h" 31 #include "public/platform/Platform.h"
32 32
33 #include <memory>
34
33 #include "base/threading/thread_task_runner_handle.h" 35 #include "base/threading/thread_task_runner_handle.h"
34 #include "base/trace_event/memory_dump_manager.h" 36 #include "base/trace_event/memory_dump_manager.h"
35 #include "platform/Histogram.h" 37 #include "platform/Histogram.h"
36 #include "platform/MemoryCoordinator.h" 38 #include "platform/MemoryCoordinator.h"
37 #include "platform/PartitionAllocMemoryDumpProvider.h" 39 #include "platform/PartitionAllocMemoryDumpProvider.h"
38 #include "platform/fonts/FontCacheMemoryDumpProvider.h" 40 #include "platform/fonts/FontCacheMemoryDumpProvider.h"
39 #include "platform/heap/BlinkGCMemoryDumpProvider.h" 41 #include "platform/heap/BlinkGCMemoryDumpProvider.h"
40 #include "platform/heap/GCTaskRunner.h" 42 #include "platform/heap/GCTaskRunner.h"
41 #include "platform/instrumentation/tracing/MemoryCacheDumpProvider.h" 43 #include "platform/instrumentation/tracing/MemoryCacheDumpProvider.h"
42 #include "public/platform/Connector.h"
43 #include "public/platform/InterfaceProvider.h" 44 #include "public/platform/InterfaceProvider.h"
44 #include "public/platform/WebPrerenderingSupport.h" 45 #include "public/platform/WebPrerenderingSupport.h"
46 #include "services/service_manager/public/cpp/connector.h"
45 #include "wtf/HashMap.h" 47 #include "wtf/HashMap.h"
46 48
47 namespace blink { 49 namespace blink {
48 50
51 namespace {
52
53 class DefaultConnector {
54 public:
55 DefaultConnector() {
56 service_manager::mojom::ConnectorRequest request;
57 m_connector = service_manager::Connector::Create(&request);
58 }
59
60 service_manager::Connector* get() { return m_connector.get(); }
61
62 private:
63 std::unique_ptr<service_manager::Connector> m_connector;
64 };
65
66 } // namespace
67
49 static Platform* s_platform = nullptr; 68 static Platform* s_platform = nullptr;
50 69
51 static GCTaskRunner* s_gcTaskRunner = nullptr; 70 static GCTaskRunner* s_gcTaskRunner = nullptr;
52 71
53 static void maxObservedSizeFunction(size_t sizeInMB) { 72 static void maxObservedSizeFunction(size_t sizeInMB) {
54 const size_t supportedMaxSizeInMB = 4 * 1024; 73 const size_t supportedMaxSizeInMB = 4 * 1024;
55 if (sizeInMB >= supportedMaxSizeInMB) 74 if (sizeInMB >= supportedMaxSizeInMB)
56 sizeInMB = supportedMaxSizeInMB - 1; 75 sizeInMB = supportedMaxSizeInMB - 1;
57 76
58 // Send a UseCounter only when we see the highest memory usage 77 // Send a UseCounter only when we see the highest memory usage
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 132 }
114 133
115 Platform* Platform::current() { 134 Platform* Platform::current() {
116 return s_platform; 135 return s_platform;
117 } 136 }
118 137
119 WebThread* Platform::mainThread() const { 138 WebThread* Platform::mainThread() const {
120 return m_mainThread; 139 return m_mainThread;
121 } 140 }
122 141
123 Connector* Platform::connector() { 142 service_manager::Connector* Platform::connector() {
124 return Connector::getEmptyConnector(); 143 DEFINE_STATIC_LOCAL(DefaultConnector, connector, ());
144 return connector.get();
125 } 145 }
126 146
127 InterfaceProvider* Platform::interfaceProvider() { 147 InterfaceProvider* Platform::interfaceProvider() {
128 return InterfaceProvider::getEmptyInterfaceProvider(); 148 return InterfaceProvider::getEmptyInterfaceProvider();
129 } 149 }
130 150
131 } // namespace blink 151 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | third_party/WebKit/Source/platform/exported/ServiceRegistry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698