OLD | NEW |
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/browser/device_orientation/message_filter.h" | 5 #include "content/browser/device_orientation/message_filter.h" |
6 | 6 |
7 #include "content/browser/device_orientation/observer_delegate.h" | 7 #include "content/browser/device_orientation/observer_delegate.h" |
8 #include "content/browser/device_orientation/provider.h" | 8 #include "content/browser/device_orientation/provider.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 DeviceOrientationMessageFilter::DeviceOrientationMessageFilter( | 13 DeviceOrientationMessageFilter::DeviceOrientationMessageFilter( |
14 DeviceData::Type device_data_type) | 14 DeviceData::Type device_data_type) |
15 : provider_(NULL), | 15 : provider_(NULL), |
16 device_data_type_(device_data_type) { | 16 device_data_type_(device_data_type) { |
17 } | 17 } |
18 | 18 |
19 DeviceOrientationMessageFilter::~DeviceOrientationMessageFilter() { | 19 DeviceOrientationMessageFilter::~DeviceOrientationMessageFilter() { |
20 } | 20 } |
21 | 21 |
22 void DeviceOrientationMessageFilter::OnStartUpdating(int render_view_id) { | 22 void DeviceOrientationMessageFilter::OnStartUpdating(int render_view_id) { |
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
24 | 24 |
25 if (!provider_) | 25 if (!provider_.get()) |
26 provider_ = Provider::GetInstance(); | 26 provider_ = Provider::GetInstance(); |
27 | 27 |
28 observers_map_[render_view_id] = new ObserverDelegate(device_data_type_, | 28 observers_map_[render_view_id] = new ObserverDelegate( |
29 provider_, render_view_id, this); | 29 device_data_type_, provider_.get(), render_view_id, this); |
30 } | 30 } |
31 | 31 |
32 void DeviceOrientationMessageFilter::OnStopUpdating(int render_view_id) { | 32 void DeviceOrientationMessageFilter::OnStopUpdating(int render_view_id) { |
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
34 | 34 |
35 observers_map_.erase(render_view_id); | 35 observers_map_.erase(render_view_id); |
36 } | 36 } |
37 | 37 |
38 } // namespace content | 38 } // namespace content |
OLD | NEW |