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

Side by Side Diff: content/renderer/mojo/blink_service_registry_wrapper.cc

Issue 1830883002: Add blink::ServiceRegistry and expose it from LocalFrame and Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/mojo/blink_service_registry_wrapper.h"
6
7 #include <utility>
8
9 #include "base/strings/string_piece.h"
10 #include "content/common/mojo/service_registry_impl.h"
11 #include "content/renderer/render_thread_impl.h"
12 #include "device/battery/battery_monitor.mojom.h"
esprehn 2016/03/29 05:26:20 this is a really bad layering violation that the c
13
14 namespace content {
15
16 BlinkServiceRegistryWrapper::BlinkServiceRegistryWrapper(
17 content::ServiceRegistry* service_registry)
18 : service_registry_(
19 static_cast<ServiceRegistryImpl*>(service_registry)->GetWeakPtr()) {}
20
21 BlinkServiceRegistryWrapper::~BlinkServiceRegistryWrapper() = default;
22
23 void BlinkServiceRegistryWrapper::connectToRemoteService(
24 const char* name,
25 mojo::ScopedMessagePipeHandle handle) {
26 if (!service_registry_)
27 return;
28
29 // In the layout test mode, mock services should be used instead.
30 // TODO(yukishiino): We'd like to inject mock services implemented in
31 // JavaScript. Remove the following hack once we support JS-bindings
32 // of Mojo and service mocking in JS.
33 if (RenderThreadImpl::current() &&
34 RenderThreadImpl::current()->layout_test_mode() &&
35 base::StringPiece(name) == device::BatteryMonitor::Name_) {
esprehn 2016/03/29 05:26:20 woah, this is a crazy hack. We really should fix t
Sam McNally 2016/03/30 00:20:53 I'm going to change battery status to avoid this:
36 return;
37 }
38
39 service_registry_->ConnectToRemoteService(name, std::move(handle));
40 }
41
42 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698