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

Side by Side Diff: content/browser/service_worker/service_worker_metrics.h

Issue 2778173002: Revert of "Speculatively launch Service Workers on mouse/touch events." (Closed)
Patch Set: rebase Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 MESSAGE = 8, 104 MESSAGE = 8,
105 NOTIFICATION_CLOSE = 9, 105 NOTIFICATION_CLOSE = 9,
106 FETCH_MAIN_FRAME = 10, 106 FETCH_MAIN_FRAME = 10,
107 FETCH_SUB_FRAME = 11, 107 FETCH_SUB_FRAME = 11,
108 FETCH_SHARED_WORKER = 12, 108 FETCH_SHARED_WORKER = 12,
109 FETCH_SUB_RESOURCE = 13, 109 FETCH_SUB_RESOURCE = 13,
110 UNKNOWN = 14, // Used when event type is not known. 110 UNKNOWN = 14, // Used when event type is not known.
111 FOREIGN_FETCH = 15, 111 FOREIGN_FETCH = 15,
112 FETCH_WAITUNTIL = 16, 112 FETCH_WAITUNTIL = 16,
113 FOREIGN_FETCH_WAITUNTIL = 17, 113 FOREIGN_FETCH_WAITUNTIL = 17,
114 NAVIGATION_HINT_LINK_MOUSE_DOWN = 18, 114 // NAVIGATION_HINT_LINK_MOUSE_DOWN = 18, // Obsolete
115 NAVIGATION_HINT_LINK_TAP_UNCONFIRMED = 19, 115 // NAVIGATION_HINT_LINK_TAP_UNCONFIRMED = 19, // Obsolete
116 NAVIGATION_HINT_LINK_TAP_DOWN = 20, 116 // NAVIGATION_HINT_LINK_TAP_DOWN = 20, // Obsolete
117 // Used when external consumers want to add a request to 117 // Used when external consumers want to add a request to
118 // ServiceWorkerVersion to keep it alive. 118 // ServiceWorkerVersion to keep it alive.
119 EXTERNAL_REQUEST = 21, 119 EXTERNAL_REQUEST = 21,
120 PAYMENT_REQUEST = 22, 120 PAYMENT_REQUEST = 22,
121 BACKGROUND_FETCH_ABORT = 23, 121 BACKGROUND_FETCH_ABORT = 23,
122 BACKGROUND_FETCH_CLICK = 24, 122 BACKGROUND_FETCH_CLICK = 24,
123 BACKGROUND_FETCH_FAIL = 25, 123 BACKGROUND_FETCH_FAIL = 25,
124 BACKGROUND_FETCHED = 26, 124 BACKGROUND_FETCHED = 26,
125 // Add new events to record here. 125 // Add new events to record here.
126 NUM_TYPES 126 NUM_TYPES
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 START_DURING_STARTUP, 170 START_DURING_STARTUP,
171 // Add new types here. 171 // Add new types here.
172 NUM_TYPES 172 NUM_TYPES
173 }; 173 };
174 174
175 // Not used for UMA. 175 // Not used for UMA.
176 enum class LoadSource { NETWORK, HTTP_CACHE, SERVICE_WORKER_STORAGE }; 176 enum class LoadSource { NETWORK, HTTP_CACHE, SERVICE_WORKER_STORAGE };
177 177
178 class ScopedEventRecorder { 178 class ScopedEventRecorder {
179 public: 179 public:
180 explicit ScopedEventRecorder(EventType start_worker_purpose); 180 explicit ScopedEventRecorder();
181 ~ScopedEventRecorder(); 181 ~ScopedEventRecorder();
182 182
183 void RecordEventHandledStatus(EventType event, bool handled); 183 void RecordEventHandledStatus(EventType event, bool handled);
184 184
185 private: 185 private:
186 struct EventStat { 186 struct EventStat {
187 size_t fired_events = 0; 187 size_t fired_events = 0;
188 size_t handled_events = 0; 188 size_t handled_events = 0;
189 }; 189 };
190 190
191 // Records how much of dispatched events are handled. 191 // Records how much of dispatched events are handled.
192 static void RecordEventHandledRatio(EventType event, 192 static void RecordEventHandledRatio(EventType event,
193 size_t handled_events, 193 size_t handled_events,
194 size_t fired_events); 194 size_t fired_events);
195 195
196 // Records the precision of the speculative launch of Service Workers for
197 // each navigation hint type. If there was no main/sub frame fetch event
198 // fired on the worker, |frame_fetch_event_fired| is false. This means that
199 // the speculative launch wasn't helpful.
200 static void RecordNavigationHintPrecision(EventType start_worker_purpose,
201 bool frame_fetch_event_fired);
202
203 std::map<EventType, EventStat> event_stats_; 196 std::map<EventType, EventStat> event_stats_;
204 const EventType start_worker_purpose_;
205 197
206 DISALLOW_COPY_AND_ASSIGN(ScopedEventRecorder); 198 DISALLOW_COPY_AND_ASSIGN(ScopedEventRecorder);
207 }; 199 };
208 200
209 // Converts an event type to a string. Used for tracing. 201 // Converts an event type to a string. Used for tracing.
210 static const char* EventTypeToString(EventType event_type); 202 static const char* EventTypeToString(EventType event_type);
211 203
212 // If the |url| is not a special site, returns Site::OTHER. 204 // If the |url| is not a special site, returns Site::OTHER.
213 static Site SiteFromURL(const GURL& url); 205 static Site SiteFromURL(const GURL& url);
214 206
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 352
361 static void RecordRuntime(base::TimeDelta time); 353 static void RecordRuntime(base::TimeDelta time);
362 354
363 private: 355 private:
364 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics); 356 DISALLOW_IMPLICIT_CONSTRUCTORS(ServiceWorkerMetrics);
365 }; 357 };
366 358
367 } // namespace content 359 } // namespace content
368 360
369 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ 361 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698