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/profiler/scoped_profile.h" | |
10 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
11 #include "chrome/browser/extensions/api/idle/idle_api_constants.h" | 10 #include "chrome/browser/extensions/api/idle/idle_api_constants.h" |
12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/extensions/api/idle.h" | 12 #include "chrome/common/extensions/api/idle.h" |
14 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
15 #include "extensions/browser/event_router.h" | 14 #include "extensions/browser/event_router.h" |
16 #include "extensions/browser/extension_registry.h" | 15 #include "extensions/browser/extension_registry.h" |
17 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
18 | 17 |
19 namespace keys = extensions::idle_api_constants; | 18 namespace keys = extensions::idle_api_constants; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 140 } |
142 | 141 |
143 void IdleManager::OnExtensionUnloaded(content::BrowserContext* browser_context, | 142 void IdleManager::OnExtensionUnloaded(content::BrowserContext* browser_context, |
144 const Extension* extension, | 143 const Extension* extension, |
145 UnloadedExtensionInfo::Reason reason) { | 144 UnloadedExtensionInfo::Reason reason) { |
146 DCHECK(thread_checker_.CalledOnValidThread()); | 145 DCHECK(thread_checker_.CalledOnValidThread()); |
147 monitors_.erase(extension->id()); | 146 monitors_.erase(extension->id()); |
148 } | 147 } |
149 | 148 |
150 void IdleManager::OnListenerAdded(const EventListenerInfo& details) { | 149 void IdleManager::OnListenerAdded(const EventListenerInfo& details) { |
151 // TODO(vadimt): Remove ScopedProfile below once crbug.com/417106 is fixed. | |
152 tracked_objects::ScopedProfile tracking_profile( | |
153 FROM_HERE_WITH_EXPLICIT_FUNCTION("IdleManager::OnListenerAdded")); | |
154 | |
155 DCHECK(thread_checker_.CalledOnValidThread()); | 150 DCHECK(thread_checker_.CalledOnValidThread()); |
156 | 151 |
157 ++GetMonitor(details.extension_id)->listeners; | 152 ++GetMonitor(details.extension_id)->listeners; |
158 StartPolling(); | 153 StartPolling(); |
159 } | 154 } |
160 | 155 |
161 void IdleManager::OnListenerRemoved(const EventListenerInfo& details) { | 156 void IdleManager::OnListenerRemoved(const EventListenerInfo& details) { |
162 DCHECK(thread_checker_.CalledOnValidThread()); | 157 DCHECK(thread_checker_.CalledOnValidThread()); |
163 | 158 |
164 // During unload the monitor could already have been deleted. No need to do | 159 // During unload the monitor could already have been deleted. No need to do |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 event_delegate_->OnStateChanged(it->first, new_state); | 260 event_delegate_->OnStateChanged(it->first, new_state); |
266 monitor.last_state = new_state; | 261 monitor.last_state = new_state; |
267 listener_count += monitor.listeners; | 262 listener_count += monitor.listeners; |
268 } | 263 } |
269 | 264 |
270 if (listener_count == 0) | 265 if (listener_count == 0) |
271 StopPolling(); | 266 StopPolling(); |
272 } | 267 } |
273 | 268 |
274 } // namespace extensions | 269 } // namespace extensions |
OLD | NEW |