diff options
author | timvolodine@chromium.org <timvolodine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-02 04:33:19 +0000 |
---|---|---|
committer | timvolodine@chromium.org <timvolodine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-02 04:33:19 +0000 |
commit | 029e6da1c9bc48fa540400814662f6cf24f537a3 (patch) | |
tree | d8365b977966e23f170fe39270376e032a33cc19 | |
parent | a4d45a029ae0eb86e1a142f6b5b12c5d2f628aaf (diff) | |
download | chromium_src-029e6da1c9bc48fa540400814662f6cf24f537a3.zip chromium_src-029e6da1c9bc48fa540400814662f6cf24f537a3.tar.gz chromium_src-029e6da1c9bc48fa540400814662f6cf24f537a3.tar.bz2 |
Remove unused Device Motion browser-side code.
Deleted motion message IPC filter, motion data and corresponding tests.
Device Motion is now implemented using shared memory, see crrev.com/18572014.
BUG=261165
Review URL: https://chromiumcodereview.appspot.com/19824002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215209 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/device_orientation/motion.cc | 66 | ||||
-rw-r--r-- | content/browser/device_orientation/motion.h | 165 | ||||
-rw-r--r-- | content/browser/device_orientation/motion_message_filter.cc | 32 | ||||
-rw-r--r-- | content/browser/device_orientation/motion_message_filter.h | 30 | ||||
-rw-r--r-- | content/browser/device_orientation/observer_delegate.cc | 4 | ||||
-rw-r--r-- | content/browser/device_orientation/provider_unittest.cc | 124 | ||||
-rw-r--r-- | content/content_browser.gypi | 4 |
7 files changed, 1 insertions, 424 deletions
diff --git a/content/browser/device_orientation/motion.cc b/content/browser/device_orientation/motion.cc deleted file mode 100644 index d5985e6..0000000 --- a/content/browser/device_orientation/motion.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2012 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/browser/device_orientation/motion.h" - -#include "content/common/device_motion_messages.h" - -namespace content { - -Motion::Motion() - : can_provide_acceleration_x_(false), - can_provide_acceleration_y_(false), - can_provide_acceleration_z_(false), - can_provide_acceleration_including_gravity_x_(false), - can_provide_acceleration_including_gravity_y_(false), - can_provide_acceleration_including_gravity_z_(false), - can_provide_rotation_rate_alpha_(false), - can_provide_rotation_rate_beta_(false), - can_provide_rotation_rate_gamma_(false), - can_provide_interval_(false) { -} - -Motion::~Motion() { -} - -IPC::Message* Motion::CreateIPCMessage(int render_view_id) const { - DeviceMotionMsg_Updated_Params params; - - params.can_provide_acceleration_x = can_provide_acceleration_x_; - params.acceleration_x = acceleration_x_; - params.can_provide_acceleration_y = can_provide_acceleration_y_; - params.acceleration_y = acceleration_y_; - params.can_provide_acceleration_z = can_provide_acceleration_z_; - params.acceleration_z = acceleration_z_; - - params.can_provide_acceleration_including_gravity_x = - can_provide_acceleration_including_gravity_x_; - params.acceleration_including_gravity_x = acceleration_including_gravity_x_; - params.can_provide_acceleration_including_gravity_y = - can_provide_acceleration_including_gravity_y_; - params.acceleration_including_gravity_y = acceleration_including_gravity_y_; - params.can_provide_acceleration_including_gravity_z = - can_provide_acceleration_including_gravity_z_; - params.acceleration_including_gravity_z = acceleration_including_gravity_z_; - - params.can_provide_rotation_rate_alpha = can_provide_rotation_rate_alpha_; - params.rotation_rate_alpha = rotation_rate_alpha_; - params.can_provide_rotation_rate_beta = can_provide_rotation_rate_beta_; - params.rotation_rate_beta = rotation_rate_beta_; - params.can_provide_rotation_rate_gamma = can_provide_rotation_rate_gamma_; - params.rotation_rate_gamma = rotation_rate_gamma_; - - params.can_provide_interval = can_provide_interval_; - params.interval = interval_; - - return new DeviceMotionMsg_Updated(render_view_id, params); -} - -// Should always fire new motion events so that they occur at regular intervals. -// The firing frequency is determined by the polling frequency in ProviderImpl. -bool Motion::ShouldFireEvent(const DeviceData* old_data) const { - return true; -} - -}; // namespace content diff --git a/content/browser/device_orientation/motion.h b/content/browser/device_orientation/motion.h deleted file mode 100644 index 8027254..0000000 --- a/content/browser/device_orientation/motion.h +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ -#define CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ - -#include "base/compiler_specific.h" -#include "content/browser/device_orientation/device_data.h" -#include "content/common/content_export.h" - -namespace content { - -class Motion : public DeviceData { - public: - // acceleration_x, acceleration_y, and acceleration_z are the accelerations - // excluding gravity along the axes specified in - // http://dev.w3.org/geo/api/spec-source-orientation.html - - // acceleration_including_gravity_x, acceleration_including_gravity_y, and - // acceleration_including_gravity_z are the accelerations including gravity - // along the same axes as above - - // rotation_rate_alpha, rotation_rate_beta, and rotataion_rate_gamma are the - // rotations around the same axes as above - - // interval is the time interval at which data is obtained from the hardware, - // as specified in the document referenced above - - // can_provide_{acceleration_x, acceleration_y, acceleration_z, - // acceleration_including_gravity_x, acceleration_including_gravity_y, - // acceleration_including_gravity_z, rotation_rate_alpha, rotation_rate_beta, - // rotation_rate_gamma, interval} is true if data can be provided for that - // variable - CONTENT_EXPORT Motion(); - - // From DeviceData. - virtual IPC::Message* CreateIPCMessage(int render_view_id) const OVERRIDE; - virtual bool ShouldFireEvent(const DeviceData* old_data) const OVERRIDE; - - void set_acceleration_x(double acceleration_x) { - can_provide_acceleration_x_ = true; - acceleration_x_ = acceleration_x; - } - bool can_provide_acceleration_x() const { - return can_provide_acceleration_x_; - } - double acceleration_x() const { return acceleration_x_; } - - void set_acceleration_y(double acceleration_y) { - can_provide_acceleration_y_ = true; - acceleration_y_ = acceleration_y; - } - bool can_provide_acceleration_y() const { - return can_provide_acceleration_y_; - } - double acceleration_y() const { return acceleration_y_; } - - void set_acceleration_z(double acceleration_z) { - can_provide_acceleration_z_ = true; - acceleration_z_ = acceleration_z; - } - bool can_provide_acceleration_z() const { - return can_provide_acceleration_z_; - } - double acceleration_z() const { return acceleration_z_; } - - void set_acceleration_including_gravity_x( - double acceleration_including_gravity_x) { - can_provide_acceleration_including_gravity_x_ = true; - acceleration_including_gravity_x_ = acceleration_including_gravity_x; - } - bool can_provide_acceleration_including_gravity_x() const { - return can_provide_acceleration_x_; - } - double acceleration_including_gravity_x() const { - return acceleration_including_gravity_x_; - } - - void set_acceleration_including_gravity_y( - double acceleration_including_gravity_y) { - can_provide_acceleration_including_gravity_y_ = true; - acceleration_including_gravity_y_ = acceleration_including_gravity_y; - } - bool can_provide_acceleration_including_gravity_y() const { - return can_provide_acceleration_y_; - } - double acceleration_including_gravity_y() const { - return acceleration_including_gravity_y_; - } - - void set_acceleration_including_gravity_z( - double acceleration_including_gravity_z) { - can_provide_acceleration_including_gravity_z_ = true; - acceleration_including_gravity_z_ = acceleration_including_gravity_z; - } - bool can_provide_acceleration_including_gravity_z() const { - return can_provide_acceleration_z_; - } - double acceleration_including_gravity_z() const { - return acceleration_including_gravity_z_; - } - - void set_rotation_rate_alpha(double rotation_rate_alpha) { - can_provide_rotation_rate_alpha_ = true; - rotation_rate_alpha_ = rotation_rate_alpha; - } - bool can_provide_rotation_rate_alpha() const { - return can_provide_rotation_rate_alpha_; - } - double rotation_rate_alpha() const { return rotation_rate_alpha_; } - - void set_rotation_rate_beta(double rotation_rate_beta) { - can_provide_rotation_rate_beta_ = true; - rotation_rate_beta_ = rotation_rate_beta; - } - bool can_provide_rotation_rate_beta() const { - return can_provide_rotation_rate_beta_; - } - double rotation_rate_beta() const { return rotation_rate_beta_; } - - void set_rotation_rate_gamma(double rotation_rate_gamma) { - can_provide_rotation_rate_gamma_ = true; - rotation_rate_gamma_ = rotation_rate_gamma; - } - bool can_provide_rotation_rate_gamma() const { - return can_provide_rotation_rate_gamma_; - } - double rotation_rate_gamma() const { return rotation_rate_gamma_; } - - void set_interval(double interval) { - can_provide_interval_ = true; - interval_ = interval; - } - bool can_provide_interval() const { return can_provide_interval_; } - double interval() const { return interval_; } - - private: - virtual ~Motion(); - - double acceleration_x_; - double acceleration_y_; - double acceleration_z_; - double acceleration_including_gravity_x_; - double acceleration_including_gravity_y_; - double acceleration_including_gravity_z_; - double rotation_rate_alpha_; - double rotation_rate_beta_; - double rotation_rate_gamma_; - double interval_; - bool can_provide_acceleration_x_; - bool can_provide_acceleration_y_; - bool can_provide_acceleration_z_; - bool can_provide_acceleration_including_gravity_x_; - bool can_provide_acceleration_including_gravity_y_; - bool can_provide_acceleration_including_gravity_z_; - bool can_provide_rotation_rate_alpha_; - bool can_provide_rotation_rate_beta_; - bool can_provide_rotation_rate_gamma_; - bool can_provide_interval_; -}; - -} // namespace content - -#endif // CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ diff --git a/content/browser/device_orientation/motion_message_filter.cc b/content/browser/device_orientation/motion_message_filter.cc deleted file mode 100644 index e837ed3..0000000 --- a/content/browser/device_orientation/motion_message_filter.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2012 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/browser/device_orientation/motion_message_filter.h" - -#include "content/browser/device_orientation/device_data.h" -#include "content/common/device_motion_messages.h" -#include "content/public/browser/browser_thread.h" - -namespace content { - -MotionMessageFilter::MotionMessageFilter() - : DeviceOrientationMessageFilter(DeviceData::kTypeMotion) { -} - -MotionMessageFilter::~MotionMessageFilter() { -} - -bool MotionMessageFilter::OnMessageReceived(const IPC::Message& message, - bool* message_was_ok) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(MotionMessageFilter, message, *message_was_ok) - IPC_MESSAGE_HANDLER(DeviceMotionHostMsg_StartUpdating, OnStartUpdating) - IPC_MESSAGE_HANDLER(DeviceMotionHostMsg_StopUpdating, OnStopUpdating) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -} // namespace content diff --git a/content/browser/device_orientation/motion_message_filter.h b/content/browser/device_orientation/motion_message_filter.h deleted file mode 100644 index cc50f67..0000000 --- a/content/browser/device_orientation/motion_message_filter.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_MESSAGE_FILTER_H_ -#define CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_MESSAGE_FILTER_H_ - -#include <map> - -#include "content/browser/device_orientation/message_filter.h" - -namespace content { - -class MotionMessageFilter : public DeviceOrientationMessageFilter { - public: - MotionMessageFilter(); - - // DeviceOrientationMessageFilter implementation. - virtual bool OnMessageReceived(const IPC::Message& message, - bool* message_was_ok) OVERRIDE; - - private: - virtual ~MotionMessageFilter(); - - DISALLOW_COPY_AND_ASSIGN(MotionMessageFilter); -}; - -} // namespace content - -#endif // CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_MESSAGE_FILTER_H_ diff --git a/content/browser/device_orientation/observer_delegate.cc b/content/browser/device_orientation/observer_delegate.cc index 1ffe07a..5c23310 100644 --- a/content/browser/device_orientation/observer_delegate.cc +++ b/content/browser/device_orientation/observer_delegate.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "content/browser/device_orientation/device_data.h" -#include "content/browser/device_orientation/motion.h" #include "content/browser/device_orientation/orientation.h" #include "ipc/ipc_sender.h" @@ -37,10 +36,9 @@ void ObserverDelegate::OnDeviceDataUpdate( DeviceData* ObserverDelegate::EmptyDeviceData(DeviceData::Type type) { switch (type) { - case DeviceData::kTypeMotion: - return new Motion(); case DeviceData::kTypeOrientation: return new Orientation(); + case DeviceData::kTypeMotion: case DeviceData::kTypeTest: NOTREACHED(); } diff --git a/content/browser/device_orientation/provider_unittest.cc b/content/browser/device_orientation/provider_unittest.cc index cc50248..1f310ea 100644 --- a/content/browser/device_orientation/provider_unittest.cc +++ b/content/browser/device_orientation/provider_unittest.cc @@ -9,7 +9,6 @@ #include "base/synchronization/lock.h" #include "content/browser/device_orientation/data_fetcher.h" #include "content/browser/device_orientation/device_data.h" -#include "content/browser/device_orientation/motion.h" #include "content/browser/device_orientation/orientation.h" #include "content/browser/device_orientation/provider.h" #include "content/browser/device_orientation/provider_impl.h" @@ -71,91 +70,6 @@ class UpdateChecker : public Provider::Observer { std::queue<scoped_refptr<const DeviceData> > expectations_queue_; }; -// Class for checking expectations on motion updates from the Provider. -class MotionUpdateChecker : public UpdateChecker { - public: - explicit MotionUpdateChecker(int* expectations_count_ptr) - : UpdateChecker(DeviceData::kTypeMotion, expectations_count_ptr) { - } - - virtual ~MotionUpdateChecker() {} - - // From UpdateChecker. - virtual void OnDeviceDataUpdate(const DeviceData* device_data, - DeviceData::Type device_data_type) OVERRIDE { - ASSERT_FALSE(expectations_queue_.empty()); - ASSERT_EQ(DeviceData::kTypeMotion, device_data_type); - - scoped_refptr<const Motion> motion(static_cast<const Motion*>(device_data)); - if (motion.get() == NULL) - motion = new Motion(); - - scoped_refptr<const Motion> expected(static_cast<const Motion*>( - (expectations_queue_.front().get()))); - expectations_queue_.pop(); - - EXPECT_EQ(expected->can_provide_acceleration_x(), - motion->can_provide_acceleration_x()); - EXPECT_EQ(expected->can_provide_acceleration_y(), - motion->can_provide_acceleration_y()); - EXPECT_EQ(expected->can_provide_acceleration_z(), - motion->can_provide_acceleration_z()); - - EXPECT_EQ(expected->can_provide_acceleration_including_gravity_x(), - motion->can_provide_acceleration_including_gravity_x()); - EXPECT_EQ(expected->can_provide_acceleration_including_gravity_y(), - motion->can_provide_acceleration_including_gravity_y()); - EXPECT_EQ(expected->can_provide_acceleration_including_gravity_z(), - motion->can_provide_acceleration_including_gravity_z()); - - EXPECT_EQ(expected->can_provide_rotation_rate_alpha(), - motion->can_provide_rotation_rate_alpha()); - EXPECT_EQ(expected->can_provide_rotation_rate_beta(), - motion->can_provide_rotation_rate_beta()); - EXPECT_EQ(expected->can_provide_rotation_rate_gamma(), - motion->can_provide_rotation_rate_gamma()); - - EXPECT_EQ(expected->can_provide_interval(), motion->can_provide_interval()); - - if (expected->can_provide_acceleration_x()) - EXPECT_EQ(expected->acceleration_x(), motion->acceleration_x()); - if (expected->can_provide_acceleration_y()) - EXPECT_EQ(expected->acceleration_y(), motion->acceleration_y()); - if (expected->can_provide_acceleration_z()) - EXPECT_EQ(expected->acceleration_z(), motion->acceleration_z()); - - if (expected->can_provide_acceleration_including_gravity_x()) - EXPECT_EQ(expected->acceleration_including_gravity_x(), - motion->acceleration_including_gravity_x()); - if (expected->can_provide_acceleration_including_gravity_y()) - EXPECT_EQ(expected->acceleration_including_gravity_y(), - motion->acceleration_including_gravity_y()); - if (expected->can_provide_acceleration_including_gravity_z()) - EXPECT_EQ(expected->acceleration_including_gravity_z(), - motion->acceleration_including_gravity_z()); - - if (expected->can_provide_rotation_rate_alpha()) - EXPECT_EQ(expected->rotation_rate_alpha(), - motion->rotation_rate_alpha()); - if (expected->can_provide_rotation_rate_beta()) - EXPECT_EQ(expected->rotation_rate_beta(), - motion->rotation_rate_beta()); - if (expected->can_provide_rotation_rate_gamma()) - EXPECT_EQ(expected->rotation_rate_gamma(), - motion->rotation_rate_gamma()); - - if (expected->can_provide_interval()) - EXPECT_EQ(expected->interval(), motion->interval()); - - --(*expectations_count_ptr_); - - if (*expectations_count_ptr_ == 0) { - base::MessageLoop::current()->PostTask(FROM_HERE, - base::MessageLoop::QuitClosure()); - } - } -}; - // Class for checking expectations on orientation updates from the Provider. class OrientationUpdateChecker : public UpdateChecker { public: @@ -612,44 +526,6 @@ TEST_F(DeviceOrientationProviderTest, StartStopStart) { MockDeviceDataFactory::SetCurInstance(NULL); } -// Tests that Motion events always fire, even if the motion is unchanged. -TEST_F(DeviceOrientationProviderTest, FLAKY_MotionAlwaysFires) { - scoped_refptr<MockDeviceDataFactory> device_data_factory( - new MockDeviceDataFactory()); - MockDeviceDataFactory::SetCurInstance(device_data_factory.get()); - Init(MockDeviceDataFactory::CreateDataFetcher); - - scoped_refptr<Motion> test_motion(new Motion()); - test_motion->set_acceleration_x(1); - test_motion->set_acceleration_y(2); - test_motion->set_acceleration_z(3); - test_motion->set_acceleration_including_gravity_x(4); - test_motion->set_acceleration_including_gravity_y(5); - test_motion->set_acceleration_including_gravity_z(6); - test_motion->set_rotation_rate_alpha(7); - test_motion->set_rotation_rate_beta(8); - test_motion->set_rotation_rate_gamma(9); - test_motion->set_interval(10); - - scoped_ptr<MotionUpdateChecker> checker(new MotionUpdateChecker( - &pending_expectations_)); - - device_data_factory->SetDeviceData(test_motion.get(), - DeviceData::kTypeMotion); - checker->AddExpectation(test_motion.get()); - provider_->AddObserver(checker.get()); - base::MessageLoop::current()->Run(); - - // The observer should receive the same motion again. - device_data_factory->SetDeviceData(test_motion.get(), - DeviceData::kTypeMotion); - checker->AddExpectation(test_motion.get()); - base::MessageLoop::current()->Run(); - - provider_->RemoveObserver(checker.get()); - MockDeviceDataFactory::SetCurInstance(NULL); -} - // Tests that Orientation events only fire if the change is significant. TEST_F(DeviceOrientationProviderTest, OrientationSignificantlyDifferent) { scoped_refptr<MockDeviceDataFactory> device_data_factory( diff --git a/content/content_browser.gypi b/content/content_browser.gypi index d57974c..1baba15 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -406,10 +406,6 @@ 'browser/device_orientation/device_motion_service.h', 'browser/device_orientation/message_filter.cc', 'browser/device_orientation/message_filter.h', - 'browser/device_orientation/motion.cc', - 'browser/device_orientation/motion.h', - 'browser/device_orientation/motion_message_filter.cc', - 'browser/device_orientation/motion_message_filter.h', 'browser/device_orientation/observer_delegate.cc', 'browser/device_orientation/observer_delegate.h', 'browser/device_orientation/orientation.cc', |