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

Side by Side Diff: content/renderer/renderer_blink_platform_impl.cc

Issue 1414573003: Rename enums in WebPlatformEventType.h to follow blink style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | content/test/layouttest_support.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/renderer_blink_platform_impl.h" 5 #include "content/renderer/renderer_blink_platform_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 876
877 WebBlobRegistry* RendererBlinkPlatformImpl::blobRegistry() { 877 WebBlobRegistry* RendererBlinkPlatformImpl::blobRegistry() {
878 // blob_registry_ can be NULL when running some tests. 878 // blob_registry_ can be NULL when running some tests.
879 return blob_registry_.get(); 879 return blob_registry_.get();
880 } 880 }
881 881
882 //------------------------------------------------------------------------------ 882 //------------------------------------------------------------------------------
883 883
884 void RendererBlinkPlatformImpl::sampleGamepads(WebGamepads& gamepads) { 884 void RendererBlinkPlatformImpl::sampleGamepads(WebGamepads& gamepads) {
885 PlatformEventObserverBase* observer = 885 PlatformEventObserverBase* observer =
886 platform_event_observers_.Lookup(blink::WebPlatformEventGamepad); 886 platform_event_observers_.Lookup(blink::WebPlatformEventTypeGamepad);
887 if (!observer) 887 if (!observer)
888 return; 888 return;
889 static_cast<RendererGamepadProvider*>(observer)->SampleGamepads(gamepads); 889 static_cast<RendererGamepadProvider*>(observer)->SampleGamepads(gamepads);
890 } 890 }
891 891
892 //------------------------------------------------------------------------------ 892 //------------------------------------------------------------------------------
893 893
894 WebMediaRecorderHandler* 894 WebMediaRecorderHandler*
895 RendererBlinkPlatformImpl::createMediaRecorderHandler() { 895 RendererBlinkPlatformImpl::createMediaRecorderHandler() {
896 #if !defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 896 #if !defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 blink::WebPlatformEventType type) { 1121 blink::WebPlatformEventType type) {
1122 RenderThread* thread = RenderThreadImpl::current(); 1122 RenderThread* thread = RenderThreadImpl::current();
1123 1123
1124 // When running layout tests, those observers should not listen to the actual 1124 // When running layout tests, those observers should not listen to the actual
1125 // hardware changes. In order to make that happen, they will receive a null 1125 // hardware changes. In order to make that happen, they will receive a null
1126 // thread. 1126 // thread.
1127 if (thread && RenderThreadImpl::current()->layout_test_mode()) 1127 if (thread && RenderThreadImpl::current()->layout_test_mode())
1128 thread = NULL; 1128 thread = NULL;
1129 1129
1130 switch (type) { 1130 switch (type) {
1131 case blink::WebPlatformEventDeviceMotion: 1131 case blink::WebPlatformEventTypeDeviceMotion:
1132 return new DeviceMotionEventPump(thread); 1132 return new DeviceMotionEventPump(thread);
1133 case blink::WebPlatformEventDeviceOrientation: 1133 case blink::WebPlatformEventTypeDeviceOrientation:
1134 return new DeviceOrientationEventPump(thread); 1134 return new DeviceOrientationEventPump(thread);
1135 case blink::WebPlatformEventDeviceLight: 1135 case blink::WebPlatformEventTypeDeviceLight:
1136 return new DeviceLightEventPump(thread); 1136 return new DeviceLightEventPump(thread);
1137 case blink::WebPlatformEventGamepad: 1137 case blink::WebPlatformEventTypeGamepad:
1138 return new GamepadSharedMemoryReader(thread); 1138 return new GamepadSharedMemoryReader(thread);
1139 case blink::WebPlatformEventScreenOrientation: 1139 case blink::WebPlatformEventTypeScreenOrientation:
1140 return new ScreenOrientationObserver(); 1140 return new ScreenOrientationObserver();
1141 default: 1141 default:
1142 // A default statement is required to prevent compilation errors when 1142 // A default statement is required to prevent compilation errors when
1143 // Blink adds a new type. 1143 // Blink adds a new type.
1144 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " 1144 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with "
1145 "unknown type."; 1145 "unknown type.";
1146 } 1146 }
1147 1147
1148 return NULL; 1148 return NULL;
1149 } 1149 }
1150 1150
1151 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( 1151 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting(
1152 blink::WebPlatformEventType type, 1152 blink::WebPlatformEventType type,
1153 scoped_ptr<PlatformEventObserverBase> observer) { 1153 scoped_ptr<PlatformEventObserverBase> observer) {
1154 DCHECK(type != blink::WebPlatformEventBattery); 1154 DCHECK(type != blink::WebPlatformEventTypeBattery);
1155 1155
1156 if (platform_event_observers_.Lookup(type)) 1156 if (platform_event_observers_.Lookup(type))
1157 platform_event_observers_.Remove(type); 1157 platform_event_observers_.Remove(type);
1158 platform_event_observers_.AddWithID(observer.release(), type); 1158 platform_event_observers_.AddWithID(observer.release(), type);
1159 } 1159 }
1160 1160
1161 void RendererBlinkPlatformImpl::startListening( 1161 void RendererBlinkPlatformImpl::startListening(
1162 blink::WebPlatformEventType type, 1162 blink::WebPlatformEventType type,
1163 blink::WebPlatformEventListener* listener) { 1163 blink::WebPlatformEventListener* listener) {
1164 if (type == blink::WebPlatformEventBattery) { 1164 if (type == blink::WebPlatformEventTypeBattery) {
1165 if (RenderThreadImpl::current() && 1165 if (RenderThreadImpl::current() &&
1166 RenderThreadImpl::current()->layout_test_mode()) { 1166 RenderThreadImpl::current()->layout_test_mode()) {
1167 g_test_battery_status_listener = 1167 g_test_battery_status_listener =
1168 static_cast<blink::WebBatteryStatusListener*>(listener); 1168 static_cast<blink::WebBatteryStatusListener*>(listener);
1169 } else { 1169 } else {
1170 battery_status_dispatcher_.reset(new BatteryStatusDispatcher( 1170 battery_status_dispatcher_.reset(new BatteryStatusDispatcher(
1171 static_cast<blink::WebBatteryStatusListener*>(listener))); 1171 static_cast<blink::WebBatteryStatusListener*>(listener)));
1172 } 1172 }
1173 return; 1173 return;
1174 } 1174 }
1175 1175
1176 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1176 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1177 if (!observer) { 1177 if (!observer) {
1178 observer = CreatePlatformEventObserverFromType(type); 1178 observer = CreatePlatformEventObserverFromType(type);
1179 if (!observer) 1179 if (!observer)
1180 return; 1180 return;
1181 platform_event_observers_.AddWithID(observer, static_cast<int32>(type)); 1181 platform_event_observers_.AddWithID(observer, static_cast<int32>(type));
1182 } 1182 }
1183 observer->Start(listener); 1183 observer->Start(listener);
1184 1184
1185 // Device events (motion, orientation and light) expect to get an event fired 1185 // Device events (motion, orientation and light) expect to get an event fired
1186 // as soon as a listener is registered if a fake data was passed before. 1186 // as soon as a listener is registered if a fake data was passed before.
1187 // TODO(mlamouri,timvolodine): make those send mock values directly instead of 1187 // TODO(mlamouri,timvolodine): make those send mock values directly instead of
1188 // using this broken pattern. 1188 // using this broken pattern.
1189 if (RenderThreadImpl::current() && 1189 if (RenderThreadImpl::current() &&
1190 RenderThreadImpl::current()->layout_test_mode() && 1190 RenderThreadImpl::current()->layout_test_mode() &&
1191 (type == blink::WebPlatformEventDeviceMotion || 1191 (type == blink::WebPlatformEventTypeDeviceMotion ||
1192 type == blink::WebPlatformEventDeviceOrientation || 1192 type == blink::WebPlatformEventTypeDeviceOrientation ||
1193 type == blink::WebPlatformEventDeviceLight)) { 1193 type == blink::WebPlatformEventTypeDeviceLight)) {
1194 SendFakeDeviceEventDataForTesting(type); 1194 SendFakeDeviceEventDataForTesting(type);
1195 } 1195 }
1196 } 1196 }
1197 1197
1198 void RendererBlinkPlatformImpl::SendFakeDeviceEventDataForTesting( 1198 void RendererBlinkPlatformImpl::SendFakeDeviceEventDataForTesting(
1199 blink::WebPlatformEventType type) { 1199 blink::WebPlatformEventType type) {
1200 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1200 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1201 CHECK(observer); 1201 CHECK(observer);
1202 1202
1203 void* data = 0; 1203 void* data = 0;
1204 1204
1205 switch (type) { 1205 switch (type) {
1206 case blink::WebPlatformEventDeviceMotion: 1206 case blink::WebPlatformEventTypeDeviceMotion:
1207 if (!(g_test_device_motion_data == 0)) 1207 if (!(g_test_device_motion_data == 0))
1208 data = &g_test_device_motion_data.Get(); 1208 data = &g_test_device_motion_data.Get();
1209 break; 1209 break;
1210 case blink::WebPlatformEventDeviceOrientation: 1210 case blink::WebPlatformEventTypeDeviceOrientation:
1211 if (!(g_test_device_orientation_data == 0)) 1211 if (!(g_test_device_orientation_data == 0))
1212 data = &g_test_device_orientation_data.Get(); 1212 data = &g_test_device_orientation_data.Get();
1213 break; 1213 break;
1214 case blink::WebPlatformEventDeviceLight: 1214 case blink::WebPlatformEventTypeDeviceLight:
1215 if (g_test_device_light_data >= 0) 1215 if (g_test_device_light_data >= 0)
1216 data = &g_test_device_light_data; 1216 data = &g_test_device_light_data;
1217 break; 1217 break;
1218 default: 1218 default:
1219 NOTREACHED(); 1219 NOTREACHED();
1220 break; 1220 break;
1221 } 1221 }
1222 1222
1223 if (!data) 1223 if (!data)
1224 return; 1224 return;
1225 1225
1226 base::ThreadTaskRunnerHandle::Get()->PostTask( 1226 base::ThreadTaskRunnerHandle::Get()->PostTask(
1227 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, 1227 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting,
1228 base::Unretained(observer), data)); 1228 base::Unretained(observer), data));
1229 } 1229 }
1230 1230
1231 void RendererBlinkPlatformImpl::stopListening( 1231 void RendererBlinkPlatformImpl::stopListening(
1232 blink::WebPlatformEventType type) { 1232 blink::WebPlatformEventType type) {
1233 if (type == blink::WebPlatformEventBattery) { 1233 if (type == blink::WebPlatformEventTypeBattery) {
1234 g_test_battery_status_listener = nullptr; 1234 g_test_battery_status_listener = nullptr;
1235 battery_status_dispatcher_.reset(); 1235 battery_status_dispatcher_.reset();
1236 return; 1236 return;
1237 } 1237 }
1238 1238
1239 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1239 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1240 if (!observer) 1240 if (!observer)
1241 return; 1241 return;
1242 observer->Stop(); 1242 observer->Stop();
1243 } 1243 }
(...skipping 17 matching lines...) Expand all
1261 //------------------------------------------------------------------------------ 1261 //------------------------------------------------------------------------------
1262 1262
1263 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( 1263 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1264 const blink::WebBatteryStatus& status) { 1264 const blink::WebBatteryStatus& status) {
1265 if (!g_test_battery_status_listener) 1265 if (!g_test_battery_status_listener)
1266 return; 1266 return;
1267 g_test_battery_status_listener->updateBatteryStatus(status); 1267 g_test_battery_status_listener->updateBatteryStatus(status);
1268 } 1268 }
1269 1269
1270 } // namespace content 1270 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/test/layouttest_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698