Re-enable index-basics-workers test to see if still times
[chromium-blink-merge.git] / content / browser / device_orientation / observer_delegate.cc
blobfc4273faaae3e9983c6d70ad84d25fe35170ad3a
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
3 // found in the LICENSE file.
5 #include "content/browser/device_orientation/observer_delegate.h"
7 #include "base/logging.h"
8 #include "content/browser/device_orientation/device_data.h"
9 #include "content/browser/device_orientation/motion.h"
10 #include "content/browser/device_orientation/orientation.h"
11 #include "ipc/ipc_sender.h"
13 namespace content {
15 ObserverDelegate::ObserverDelegate(DeviceData::Type device_data_type,
16 Provider* provider, int render_view_id,
17 IPC::Sender* sender)
18 : Observer(device_data_type),
19 provider_(provider),
20 render_view_id_(render_view_id),
21 sender_(sender) {
22 provider_->AddObserver(this);
25 ObserverDelegate::~ObserverDelegate() {
26 provider_->RemoveObserver(this);
29 void ObserverDelegate::OnDeviceDataUpdate(
30 const DeviceData* device_data, DeviceData::Type device_data_type) {
31 scoped_refptr<const DeviceData> new_device_data(device_data);
32 if (!new_device_data)
33 new_device_data = EmptyDeviceData(device_data_type);
35 sender_->Send(new_device_data->CreateIPCMessage(render_view_id_));
38 DeviceData* ObserverDelegate::EmptyDeviceData(DeviceData::Type type) {
39 switch (type) {
40 case DeviceData::kTypeMotion:
41 return new Motion();
42 case DeviceData::kTypeOrientation:
43 return new Orientation();
44 case DeviceData::kTypeTest:
45 NOTREACHED();
47 NOTREACHED();
48 return NULL;
51 } // namespace content