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

Unified Diff: content/renderer/device_sensors/device_sensor_event_pump.cc

Issue 446603002: Refactor code listening to platform events in content/renderer/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webkitplatform_impl_start_stop
Patch Set: rebase Created 6 years, 4 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/device_sensors/device_sensor_event_pump.cc
diff --git a/content/renderer/device_sensors/device_sensor_event_pump.cc b/content/renderer/device_sensors/device_sensor_event_pump.cc
deleted file mode 100644
index eed3af27c0349432ffd9ba16acd5d8e4db138191..0000000000000000000000000000000000000000
--- a/content/renderer/device_sensors/device_sensor_event_pump.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2014 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 "device_sensor_event_pump.h"
-
-#include "base/logging.h"
-#include "content/public/renderer/render_thread.h"
-
-namespace content {
-
-// Default interval between successive polls, should take into account the
-// value of |kInertialSensorIntervalMillis| in
-// content/browser/device_sensors/inertial_sensor_consts.h.
-const int DeviceSensorEventPump::kDefaultPumpDelayMillis = 50;
-
-int DeviceSensorEventPump::GetDelayMillis() const {
- return pump_delay_millis_;
-}
-
-DeviceSensorEventPump::DeviceSensorEventPump()
- : pump_delay_millis_(kDefaultPumpDelayMillis),
- state_(STOPPED) {
-}
-
-DeviceSensorEventPump::DeviceSensorEventPump(int pump_delay_millis)
- : pump_delay_millis_(pump_delay_millis),
- state_(STOPPED) {
- DCHECK_GE(pump_delay_millis_, 0);
-}
-
-DeviceSensorEventPump::~DeviceSensorEventPump() {
-}
-
-bool DeviceSensorEventPump::RequestStart() {
- DVLOG(2) << "requested start";
-
- if (state_ != STOPPED)
- return false;
-
- DCHECK(!timer_.IsRunning());
-
- if (SendStartMessage()) {
- state_ = PENDING_START;
- return true;
- }
- return false;
-}
-
-bool DeviceSensorEventPump::Stop() {
- DVLOG(2) << "stop";
-
- if (state_ == STOPPED)
- return true;
-
- DCHECK((state_ == PENDING_START && !timer_.IsRunning()) ||
- (state_ == RUNNING && timer_.IsRunning()));
-
- if (timer_.IsRunning())
- timer_.Stop();
- SendStopMessage();
- state_ = STOPPED;
- return true;
-}
-
-void DeviceSensorEventPump::Attach(RenderThread* thread) {
- if (!thread)
- return;
- thread->AddObserver(this);
-}
-
-void DeviceSensorEventPump::OnDidStart(base::SharedMemoryHandle handle) {
- DVLOG(2) << "did start sensor event pump";
-
- if (state_ != PENDING_START)
- return;
-
- DCHECK(!timer_.IsRunning());
-
- if (InitializeReader(handle)) {
- timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(GetDelayMillis()),
- this, &DeviceSensorEventPump::FireEvent);
- state_ = RUNNING;
- }
-}
-
-} // namespace content
« no previous file with comments | « content/renderer/device_sensors/device_sensor_event_pump.h ('k') | content/renderer/gamepad_shared_memory_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698