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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698