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

Unified Diff: content/renderer/renderer_blink_platform_impl.cc

Issue 1538803002: Migrates battery_status from content/renderer/ to WebKit/platform/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synced. Created 4 years, 10 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/renderer_blink_platform_impl.cc
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
index e2d537f0f841c29ecced8e3d6aae036b9bb7934c..5ef967ff13781964c738c093bb290e854658fc53 100644
--- a/content/renderer/renderer_blink_platform_impl.cc
+++ b/content/renderer/renderer_blink_platform_impl.cc
@@ -52,7 +52,6 @@
#include "content/public/common/webplugininfo.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/public/renderer/media_stream_api.h"
-#include "content/renderer/battery_status/battery_status_dispatcher.h"
#include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h"
#include "content/renderer/device_sensors/device_light_event_pump.h"
#include "content/renderer/device_sensors/device_motion_event_pump.h"
@@ -85,7 +84,6 @@
#include "storage/common/quota/quota_types.h"
#include "third_party/WebKit/public/platform/FilePathConversion.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
-#include "third_party/WebKit/public/platform/WebBatteryStatusListener.h"
#include "third_party/WebKit/public/platform/WebBlobRegistry.h"
#include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
#include "third_party/WebKit/public/platform/WebFileInfo.h"
@@ -178,9 +176,6 @@ base::LazyInstance<blink::WebDeviceMotionData>::Leaky
g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
-// Set in startListening() when running layout tests, unset in stopListening(),
-// not owned by us.
-blink::WebBatteryStatusListener* g_test_battery_status_listener = nullptr;
} // namespace
@@ -1158,28 +1153,31 @@ RendererBlinkPlatformImpl::CreatePlatformEventObserverFromType(
void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting(
blink::WebPlatformEventType type,
scoped_ptr<PlatformEventObserverBase> observer) {
- DCHECK(type != blink::WebPlatformEventTypeBattery);
-
if (platform_event_observers_.Lookup(type))
platform_event_observers_.Remove(type);
platform_event_observers_.AddWithID(observer.release(), type);
}
-void RendererBlinkPlatformImpl::startListening(
- blink::WebPlatformEventType type,
- blink::WebPlatformEventListener* listener) {
- if (type == blink::WebPlatformEventTypeBattery) {
- if (RenderThreadImpl::current() &&
- RenderThreadImpl::current()->layout_test_mode()) {
- g_test_battery_status_listener =
- static_cast<blink::WebBatteryStatusListener*>(listener);
- } else {
- battery_status_dispatcher_.reset(new BatteryStatusDispatcher(
- static_cast<blink::WebBatteryStatusListener*>(listener)));
- }
+void RendererBlinkPlatformImpl::connectToRemoteService(
+ const char* name,
+ mojo::ScopedMessagePipeHandle handle) {
+ // 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())
return;
+
+ if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) {
+ // registry can be null during testing.
+ registry->ConnectToRemoteService(name, std::move(handle));
}
+}
+void RendererBlinkPlatformImpl::startListening(
+ blink::WebPlatformEventType type,
+ blink::WebPlatformEventListener* listener) {
PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
if (!observer) {
observer = CreatePlatformEventObserverFromType(type);
@@ -1239,12 +1237,6 @@ void RendererBlinkPlatformImpl::SendFakeDeviceEventDataForTesting(
void RendererBlinkPlatformImpl::stopListening(
blink::WebPlatformEventType type) {
- if (type == blink::WebPlatformEventTypeBattery) {
- g_test_battery_status_listener = nullptr;
- battery_status_dispatcher_.reset();
- return;
- }
-
PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
if (!observer)
return;
@@ -1269,15 +1261,6 @@ void RendererBlinkPlatformImpl::queryStorageUsageAndQuota(
//------------------------------------------------------------------------------
-void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
- const blink::WebBatteryStatus& status) {
- if (!g_test_battery_status_listener)
- return;
- g_test_battery_status_listener->updateBatteryStatus(status);
-}
-
-//------------------------------------------------------------------------------
-
blink::WebTrialTokenValidator*
RendererBlinkPlatformImpl::trialTokenValidator() {
return &trial_token_validator_;
« no previous file with comments | « content/renderer/renderer_blink_platform_impl.h ('k') | content/shell/renderer/layout_test/blink_test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698