| 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/provider_impl.h" | 5 #include "content/browser/device_orientation/provider_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 void ProviderImpl::PollingThread::Initialize(DataFetcherFactory factory, | 84 void ProviderImpl::PollingThread::Initialize(DataFetcherFactory factory, |
| 85 DeviceData::Type type) { | 85 DeviceData::Type type) { |
| 86 DCHECK(MessageLoop::current() == message_loop()); | 86 DCHECK(MessageLoop::current() == message_loop()); |
| 87 | 87 |
| 88 if (factory != NULL) { | 88 if (factory != NULL) { |
| 89 // Try to use factory to create a fetcher that can provide this type of | 89 // Try to use factory to create a fetcher that can provide this type of |
| 90 // data. If factory creates a fetcher that provides this type of data, | 90 // data. If factory creates a fetcher that provides this type of data, |
| 91 // start polling. | 91 // start polling. |
| 92 scoped_ptr<DataFetcher> fetcher(factory()); | 92 scoped_ptr<DataFetcher> fetcher(factory()); |
| 93 | 93 |
| 94 if (fetcher.get()) { | 94 if (fetcher) { |
| 95 scoped_refptr<const DeviceData> device_data(fetcher->GetDeviceData(type)); | 95 scoped_refptr<const DeviceData> device_data(fetcher->GetDeviceData(type)); |
| 96 if (device_data != NULL) { | 96 if (device_data != NULL) { |
| 97 // Pass ownership of fetcher to provider_. | 97 // Pass ownership of fetcher to provider_. |
| 98 data_fetcher_.swap(fetcher); | 98 data_fetcher_.swap(fetcher); |
| 99 last_device_data_map_[type] = device_data; | 99 last_device_data_map_[type] = device_data; |
| 100 | 100 |
| 101 // Notify observers. | 101 // Notify observers. |
| 102 ScheduleDoNotify(device_data, type); | 102 ScheduleDoNotify(device_data, type); |
| 103 | 103 |
| 104 // Start polling. | 104 // Start polling. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 observers_.erase(current); | 284 observers_.erase(current); |
| 285 } | 285 } |
| 286 | 286 |
| 287 if (observers_.empty()) | 287 if (observers_.empty()) |
| 288 Stop(); | 288 Stop(); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 | 292 |
| 293 } // namespace content | 293 } // namespace content |
| OLD | NEW |