Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |