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 "extensions/browser/event_router.h" | 5 #include "extensions/browser/event_router.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <tuple> | 9 #include <tuple> |
10 #include <utility> | 10 #include <utility> |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 | 753 |
754 void EventRouter::ReportEvent(events::HistogramValue histogram_value, | 754 void EventRouter::ReportEvent(events::HistogramValue histogram_value, |
755 const Extension* extension, | 755 const Extension* extension, |
756 bool did_enqueue) { | 756 bool did_enqueue) { |
757 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 757 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
758 | 758 |
759 // Record every event fired. | 759 // Record every event fired. |
760 UMA_HISTOGRAM_ENUMERATION("Extensions.Events.Dispatch", histogram_value, | 760 UMA_HISTOGRAM_ENUMERATION("Extensions.Events.Dispatch", histogram_value, |
761 events::ENUM_BOUNDARY); | 761 events::ENUM_BOUNDARY); |
762 | 762 |
| 763 bool is_component = Manifest::IsComponentLocation(extension->location()); |
| 764 |
763 // Record events for component extensions. These should be kept to a minimum, | 765 // Record events for component extensions. These should be kept to a minimum, |
764 // especially if they wake its event page. Component extensions should use | 766 // especially if they wake its event page. Component extensions should use |
765 // declarative APIs as much as possible. | 767 // declarative APIs as much as possible. |
766 if (Manifest::IsComponentLocation(extension->location())) { | 768 if (is_component) { |
767 UMA_HISTOGRAM_ENUMERATION("Extensions.Events.DispatchToComponent", | 769 UMA_HISTOGRAM_ENUMERATION("Extensions.Events.DispatchToComponent", |
768 histogram_value, events::ENUM_BOUNDARY); | 770 histogram_value, events::ENUM_BOUNDARY); |
769 } | 771 } |
770 | 772 |
771 // Record events for background pages, if any. The most important statistic | 773 // Record events for background pages, if any. The most important statistic |
772 // is DispatchWithSuspendedEventPage. Events reported there woke an event | 774 // is DispatchWithSuspendedEventPage. Events reported there woke an event |
773 // page. Implementing either filtered or declarative versions of these events | 775 // page. Implementing either filtered or declarative versions of these events |
774 // should be prioritised. | 776 // should be prioritised. |
775 // | 777 // |
776 // Note: all we know is that the extension *has* a persistent or event page, | 778 // Note: all we know is that the extension *has* a persistent or event page, |
777 // not that the event is being dispatched *to* such a page. However, this is | 779 // not that the event is being dispatched *to* such a page. However, this is |
778 // academic, since extensions with any background page have that background | 780 // academic, since extensions with any background page have that background |
779 // page running (or in the case of suspended event pages, must be started) | 781 // page running (or in the case of suspended event pages, must be started) |
780 // regardless of where the event is being dispatched. Events are dispatched | 782 // regardless of where the event is being dispatched. Events are dispatched |
781 // to a *process* not a *frame*. | 783 // to a *process* not a *frame*. |
782 if (BackgroundInfo::HasPersistentBackgroundPage(extension)) { | 784 if (BackgroundInfo::HasPersistentBackgroundPage(extension)) { |
783 UMA_HISTOGRAM_ENUMERATION( | 785 UMA_HISTOGRAM_ENUMERATION( |
784 "Extensions.Events.DispatchWithPersistentBackgroundPage", | 786 "Extensions.Events.DispatchWithPersistentBackgroundPage", |
785 histogram_value, events::ENUM_BOUNDARY); | 787 histogram_value, events::ENUM_BOUNDARY); |
786 } else if (BackgroundInfo::HasLazyBackgroundPage(extension)) { | 788 } else if (BackgroundInfo::HasLazyBackgroundPage(extension)) { |
787 if (did_enqueue) { | 789 if (did_enqueue) { |
788 UMA_HISTOGRAM_ENUMERATION( | 790 UMA_HISTOGRAM_ENUMERATION( |
789 "Extensions.Events.DispatchWithSuspendedEventPage", histogram_value, | 791 "Extensions.Events.DispatchWithSuspendedEventPage", histogram_value, |
790 events::ENUM_BOUNDARY); | 792 events::ENUM_BOUNDARY); |
| 793 if (is_component) { |
| 794 UMA_HISTOGRAM_ENUMERATION( |
| 795 "Extensions.Events.DispatchToComponentWithSuspendedEventPage", |
| 796 histogram_value, |
| 797 events::ENUM_BOUNDARY); |
| 798 } |
791 } else { | 799 } else { |
792 UMA_HISTOGRAM_ENUMERATION( | 800 UMA_HISTOGRAM_ENUMERATION( |
793 "Extensions.Events.DispatchWithRunningEventPage", histogram_value, | 801 "Extensions.Events.DispatchWithRunningEventPage", histogram_value, |
794 events::ENUM_BOUNDARY); | 802 events::ENUM_BOUNDARY); |
795 } | 803 } |
796 } | 804 } |
797 } | 805 } |
798 | 806 |
799 void EventRouter::DispatchPendingEvent(const linked_ptr<Event>& event, | 807 void EventRouter::DispatchPendingEvent(const linked_ptr<Event>& event, |
800 ExtensionHost* host) { | 808 ExtensionHost* host) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 const std::string& extension_id, | 912 const std::string& extension_id, |
905 const GURL& listener_url, | 913 const GURL& listener_url, |
906 content::BrowserContext* browser_context) | 914 content::BrowserContext* browser_context) |
907 : event_name(event_name), | 915 : event_name(event_name), |
908 extension_id(extension_id), | 916 extension_id(extension_id), |
909 listener_url(listener_url), | 917 listener_url(listener_url), |
910 browser_context(browser_context) { | 918 browser_context(browser_context) { |
911 } | 919 } |
912 | 920 |
913 } // namespace extensions | 921 } // namespace extensions |
OLD | NEW |