Index: content/renderer/mojo/blink_service_registry_wrapper.cc |
diff --git a/content/renderer/mojo/blink_service_registry_wrapper.cc b/content/renderer/mojo/blink_service_registry_wrapper.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..492faebcf68e5ab62e26eb2383b197d43f59fd5c |
--- /dev/null |
+++ b/content/renderer/mojo/blink_service_registry_wrapper.cc |
@@ -0,0 +1,42 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/renderer/mojo/blink_service_registry_wrapper.h" |
+ |
+#include <utility> |
+ |
+#include "base/strings/string_piece.h" |
+#include "content/common/mojo/service_registry_impl.h" |
+#include "content/renderer/render_thread_impl.h" |
+#include "device/battery/battery_monitor.mojom.h" |
esprehn
2016/03/29 05:26:20
this is a really bad layering violation that the c
|
+ |
+namespace content { |
+ |
+BlinkServiceRegistryWrapper::BlinkServiceRegistryWrapper( |
+ content::ServiceRegistry* service_registry) |
+ : service_registry_( |
+ static_cast<ServiceRegistryImpl*>(service_registry)->GetWeakPtr()) {} |
+ |
+BlinkServiceRegistryWrapper::~BlinkServiceRegistryWrapper() = default; |
+ |
+void BlinkServiceRegistryWrapper::connectToRemoteService( |
+ const char* name, |
+ mojo::ScopedMessagePipeHandle handle) { |
+ if (!service_registry_) |
+ return; |
+ |
+ // In the layout test mode, mock services should be used instead. |
+ // TODO(yukishiino): We'd like to inject mock services implemented in |
+ // JavaScript. Remove the following hack once we support JS-bindings |
+ // of Mojo and service mocking in JS. |
+ if (RenderThreadImpl::current() && |
+ RenderThreadImpl::current()->layout_test_mode() && |
+ 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:
|
+ return; |
+ } |
+ |
+ service_registry_->ConnectToRemoteService(name, std::move(handle)); |
+} |
+ |
+} // namespace content |