Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: extensions/browser/event_router.cc

Issue 1606943005: Adds UMA for counting component event page wakeups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds histogram expectations, and some comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | extensions/browser/event_router_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, events::ENUM_BOUNDARY);
797 }
791 } else { 798 } else {
792 UMA_HISTOGRAM_ENUMERATION( 799 UMA_HISTOGRAM_ENUMERATION(
793 "Extensions.Events.DispatchWithRunningEventPage", histogram_value, 800 "Extensions.Events.DispatchWithRunningEventPage", histogram_value,
794 events::ENUM_BOUNDARY); 801 events::ENUM_BOUNDARY);
795 } 802 }
796 } 803 }
797 } 804 }
798 805
799 void EventRouter::DispatchPendingEvent(const linked_ptr<Event>& event, 806 void EventRouter::DispatchPendingEvent(const linked_ptr<Event>& event,
800 ExtensionHost* host) { 807 ExtensionHost* host) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 const std::string& extension_id, 911 const std::string& extension_id,
905 const GURL& listener_url, 912 const GURL& listener_url,
906 content::BrowserContext* browser_context) 913 content::BrowserContext* browser_context)
907 : event_name(event_name), 914 : event_name(event_name),
908 extension_id(extension_id), 915 extension_id(extension_id),
909 listener_url(listener_url), 916 listener_url(listener_url),
910 browser_context(browser_context) { 917 browser_context(browser_context) {
911 } 918 }
912 919
913 } // namespace extensions 920 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/event_router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698