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 #ifndef CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/hash_tables.h" | 15 #include "base/hash_tables.h" |
16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/extensions/event_listener_map.h" | 19 #include "chrome/browser/extensions/event_listener_map.h" |
| 20 #include "chrome/browser/extensions/extension_event_histogram_value.h" |
20 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
21 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
22 #include "extensions/common/event_filtering_info.h" | 23 #include "extensions/common/event_filtering_info.h" |
23 #include "ipc/ipc_sender.h" | 24 #include "ipc/ipc_sender.h" |
24 | 25 |
25 class GURL; | 26 class GURL; |
26 class Profile; | 27 class Profile; |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 class BrowserContext; | 30 class BrowserContext; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 const linked_ptr<Event>& event); | 217 const linked_ptr<Event>& event); |
217 | 218 |
218 // Track of the number of dispatched events that have not yet sent an | 219 // Track of the number of dispatched events that have not yet sent an |
219 // ACK from the renderer. | 220 // ACK from the renderer. |
220 void IncrementInFlightEvents(Profile* profile, | 221 void IncrementInFlightEvents(Profile* profile, |
221 const Extension* extension); | 222 const Extension* extension); |
222 | 223 |
223 void DispatchPendingEvent(const linked_ptr<Event>& event, | 224 void DispatchPendingEvent(const linked_ptr<Event>& event, |
224 ExtensionHost* host); | 225 ExtensionHost* host); |
225 | 226 |
| 227 void RecordEventListenerAdded(const std::string& event_name); |
| 228 |
226 // Implementation of EventListenerMap::Delegate. | 229 // Implementation of EventListenerMap::Delegate. |
227 virtual void OnListenerAdded(const EventListener* listener) OVERRIDE; | 230 virtual void OnListenerAdded(const EventListener* listener) OVERRIDE; |
228 virtual void OnListenerRemoved(const EventListener* listener) OVERRIDE; | 231 virtual void OnListenerRemoved(const EventListener* listener) OVERRIDE; |
229 | 232 |
230 Profile* profile_; | 233 Profile* profile_; |
231 | 234 |
232 content::NotificationRegistrar registrar_; | 235 content::NotificationRegistrar registrar_; |
233 | 236 |
234 EventListenerMap listeners_; | 237 EventListenerMap listeners_; |
235 | 238 |
| 239 std::map<std::string, extensions::events::HistogramValue> histogram_values_; |
| 240 |
236 typedef base::hash_map<std::string, Observer*> ObserverMap; | 241 typedef base::hash_map<std::string, Observer*> ObserverMap; |
237 ObserverMap observers_; | 242 ObserverMap observers_; |
238 | 243 |
239 ActivityLog* activity_log_; | 244 ActivityLog* activity_log_; |
240 | 245 |
241 // True if we should dispatch the event signalling that Chrome was updated | 246 // True if we should dispatch the event signalling that Chrome was updated |
242 // upon loading an extension. | 247 // upon loading an extension. |
243 bool dispatch_chrome_updated_event_; | 248 bool dispatch_chrome_updated_event_; |
244 | 249 |
245 DISALLOW_COPY_AND_ASSIGN(EventRouter); | 250 DISALLOW_COPY_AND_ASSIGN(EventRouter); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 EventListenerInfo(const std::string& event_name, | 307 EventListenerInfo(const std::string& event_name, |
303 const std::string& extension_id); | 308 const std::string& extension_id); |
304 | 309 |
305 const std::string event_name; | 310 const std::string event_name; |
306 const std::string extension_id; | 311 const std::string extension_id; |
307 }; | 312 }; |
308 | 313 |
309 } // namespace extensions | 314 } // namespace extensions |
310 | 315 |
311 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ | 316 #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
OLD | NEW |