| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_sensors/data_fetcher_shared_memory_base.h" | 5 #include "content/browser/device_sensors/data_fetcher_shared_memory_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 this, &PollingThread::DoPoll); | 84 this, &PollingThread::DoPoll); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 void DataFetcherSharedMemoryBase::PollingThread::RemoveConsumer( | 88 void DataFetcherSharedMemoryBase::PollingThread::RemoveConsumer( |
| 89 ConsumerType consumer_type) { | 89 ConsumerType consumer_type) { |
| 90 DCHECK(fetcher_); | 90 DCHECK(fetcher_); |
| 91 if (!fetcher_->Stop(consumer_type)) | 91 if (!fetcher_->Stop(consumer_type)) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 consumers_bitmask_ ^= consumer_type; | 94 consumers_bitmask_ &= ~consumer_type; |
| 95 | 95 |
| 96 if (!consumers_bitmask_) | 96 if (!consumers_bitmask_) |
| 97 timer_.reset(); // will also stop the timer. | 97 timer_.reset(); // will also stop the timer. |
| 98 } | 98 } |
| 99 | 99 |
| 100 void DataFetcherSharedMemoryBase::PollingThread::DoPoll() { | 100 void DataFetcherSharedMemoryBase::PollingThread::DoPoll() { |
| 101 DCHECK(fetcher_); | 101 DCHECK(fetcher_); |
| 102 DCHECK(consumers_bitmask_); | 102 DCHECK(consumers_bitmask_); |
| 103 fetcher_->Fetch(consumers_bitmask_); | 103 fetcher_->Fetch(consumers_bitmask_); |
| 104 } | 104 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 base::MessageLoop* DataFetcherSharedMemoryBase::GetPollingMessageLoop() const { | 245 base::MessageLoop* DataFetcherSharedMemoryBase::GetPollingMessageLoop() const { |
| 246 return polling_thread_ ? polling_thread_->message_loop() : nullptr; | 246 return polling_thread_ ? polling_thread_->message_loop() : nullptr; |
| 247 } | 247 } |
| 248 | 248 |
| 249 bool DataFetcherSharedMemoryBase::IsPollingTimerRunningForTesting() const { | 249 bool DataFetcherSharedMemoryBase::IsPollingTimerRunningForTesting() const { |
| 250 return polling_thread_ ? polling_thread_->IsTimerRunning() : false; | 250 return polling_thread_ ? polling_thread_->IsTimerRunning() : false; |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // namespace content | 253 } // namespace content |
| OLD | NEW |