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