| 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 "chrome/browser/extensions/api/idle/idle_manager.h" | 5 #include "chrome/browser/extensions/api/idle/idle_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/extensions/api/idle/idle_api_constants.h" | 10 #include "chrome/browser/extensions/api/idle/idle_api_constants.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 IdleMonitor::IdleMonitor(IdleState initial_state) | 115 IdleMonitor::IdleMonitor(IdleState initial_state) |
| 116 : last_state(initial_state), | 116 : last_state(initial_state), |
| 117 listeners(0), | 117 listeners(0), |
| 118 threshold(kDefaultIdleThreshold) { | 118 threshold(kDefaultIdleThreshold) { |
| 119 } | 119 } |
| 120 | 120 |
| 121 IdleManager::IdleManager(Profile* profile) | 121 IdleManager::IdleManager(Profile* profile) |
| 122 : profile_(profile), | 122 : profile_(profile), |
| 123 last_state_(IDLE_STATE_ACTIVE), | 123 last_state_(IDLE_STATE_ACTIVE), |
| 124 weak_factory_(this), | |
| 125 idle_time_provider_(new DefaultIdleProvider()), | 124 idle_time_provider_(new DefaultIdleProvider()), |
| 126 event_delegate_(new DefaultEventDelegate(profile)), | 125 event_delegate_(new DefaultEventDelegate(profile)), |
| 127 extension_registry_observer_(this) { | 126 extension_registry_observer_(this), |
| 127 weak_factory_(this) { |
| 128 } | 128 } |
| 129 | 129 |
| 130 IdleManager::~IdleManager() { | 130 IdleManager::~IdleManager() { |
| 131 } | 131 } |
| 132 | 132 |
| 133 void IdleManager::Init() { | 133 void IdleManager::Init() { |
| 134 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 134 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
| 135 event_delegate_->RegisterObserver(this); | 135 event_delegate_->RegisterObserver(this); |
| 136 } | 136 } |
| 137 | 137 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 event_delegate_->OnStateChanged(it->first, new_state); | 261 event_delegate_->OnStateChanged(it->first, new_state); |
| 262 monitor.last_state = new_state; | 262 monitor.last_state = new_state; |
| 263 listener_count += monitor.listeners; | 263 listener_count += monitor.listeners; |
| 264 } | 264 } |
| 265 | 265 |
| 266 if (listener_count == 0) | 266 if (listener_count == 0) |
| 267 StopPolling(); | 267 StopPolling(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 } // namespace extensions | 270 } // namespace extensions |
| OLD | NEW |