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

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

Issue 2218943002: Introduce ServiceWorker.EventDispatchingDelay UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated mpearson@'s comment Created 4 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_VERSION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <functional> 10 #include <functional>
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <queue> 13 #include <queue>
14 #include <set> 14 #include <set>
15 #include <string> 15 #include <string>
16 #include <utility> 16 #include <utility>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/callback.h" 19 #include "base/callback.h"
20 #include "base/containers/scoped_ptr_hash_map.h" 20 #include "base/containers/scoped_ptr_hash_map.h"
21 #include "base/gtest_prod_util.h" 21 #include "base/gtest_prod_util.h"
22 #include "base/id_map.h" 22 #include "base/id_map.h"
23 #include "base/macros.h" 23 #include "base/macros.h"
24 #include "base/memory/ptr_util.h" 24 #include "base/memory/ptr_util.h"
25 #include "base/memory/ref_counted.h" 25 #include "base/memory/ref_counted.h"
26 #include "base/observer_list.h" 26 #include "base/observer_list.h"
27 #include "base/optional.h" 27 #include "base/optional.h"
28 #include "base/threading/thread_task_runner_handle.h" 28 #include "base/threading/thread_task_runner_handle.h"
29 #include "base/time/time.h"
29 #include "base/timer/timer.h" 30 #include "base/timer/timer.h"
30 #include "content/browser/service_worker/embedded_worker_instance.h" 31 #include "content/browser/service_worker/embedded_worker_instance.h"
31 #include "content/browser/service_worker/embedded_worker_status.h" 32 #include "content/browser/service_worker/embedded_worker_status.h"
32 #include "content/browser/service_worker/service_worker_metrics.h" 33 #include "content/browser/service_worker/service_worker_metrics.h"
33 #include "content/browser/service_worker/service_worker_script_cache_map.h" 34 #include "content/browser/service_worker/service_worker_script_cache_map.h"
34 #include "content/common/content_export.h" 35 #include "content/common/content_export.h"
35 #include "content/common/service_worker/service_worker_status_code.h" 36 #include "content/common/service_worker/service_worker_status_code.h"
36 #include "content/common/service_worker/service_worker_types.h" 37 #include "content/common/service_worker/service_worker_types.h"
37 #include "ipc/ipc_message.h" 38 #include "ipc/ipc_message.h"
38 #include "mojo/public/cpp/bindings/interface_ptr.h" 39 #include "mojo/public/cpp/bindings/interface_ptr.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 const StatusCallback& error_callback, 233 const StatusCallback& error_callback,
233 const base::TimeDelta& timeout, 234 const base::TimeDelta& timeout,
234 TimeoutBehavior timeout_behavior); 235 TimeoutBehavior timeout_behavior);
235 236
236 // Informs ServiceWorkerVersion that an event has finished being dispatched. 237 // Informs ServiceWorkerVersion that an event has finished being dispatched.
237 // Returns false if no pending requests with the provided id exist, for 238 // Returns false if no pending requests with the provided id exist, for
238 // example if the request has already timed out. 239 // example if the request has already timed out.
239 // Pass the result of the event to |was_handled|, which is used to record 240 // Pass the result of the event to |was_handled|, which is used to record
240 // statistics based on the event status. 241 // statistics based on the event status.
241 // TODO(mek): Use something other than a bool for event status. 242 // TODO(mek): Use something other than a bool for event status.
242 bool FinishRequest(int request_id, bool was_handled); 243 bool FinishRequest(int request_id,
244 bool was_handled,
245 base::Time dispatch_event_time);
243 246
244 // Connects to a specific mojo service exposed by the (running) service 247 // Connects to a specific mojo service exposed by the (running) service
245 // worker. If a connection to a service for the same Interface already exists 248 // worker. If a connection to a service for the same Interface already exists
246 // this will return that existing connection. The |request_id| must be a value 249 // this will return that existing connection. The |request_id| must be a value
247 // previously returned by StartRequest. If the connection to the service 250 // previously returned by StartRequest. If the connection to the service
248 // fails or closes before the request finished, the error callback associated 251 // fails or closes before the request finished, the error callback associated
249 // with |request_id| is called. 252 // with |request_id| is called.
250 // Only call GetMojoServiceForRequest once for a specific |request_id|. 253 // Only call GetMojoServiceForRequest once for a specific |request_id|.
251 template <typename Interface> 254 template <typename Interface>
252 base::WeakPtr<Interface> GetMojoServiceForRequest(int request_id); 255 base::WeakPtr<Interface> GetMojoServiceForRequest(int request_id);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 ~RequestInfo(); 421 ~RequestInfo();
419 bool operator>(const RequestInfo& other) const; 422 bool operator>(const RequestInfo& other) const;
420 int id; 423 int id;
421 ServiceWorkerMetrics::EventType event_type; 424 ServiceWorkerMetrics::EventType event_type;
422 base::TimeTicks expiration; 425 base::TimeTicks expiration;
423 TimeoutBehavior timeout_behavior; 426 TimeoutBehavior timeout_behavior;
424 }; 427 };
425 428
426 struct PendingRequest { 429 struct PendingRequest {
427 PendingRequest(const StatusCallback& error_callback, 430 PendingRequest(const StatusCallback& error_callback,
428 const base::TimeTicks& time, 431 base::Time time,
432 const base::TimeTicks& time_ticks,
429 ServiceWorkerMetrics::EventType event_type); 433 ServiceWorkerMetrics::EventType event_type);
430 ~PendingRequest(); 434 ~PendingRequest();
431 435
432 // ------------------------------------------------------------------------ 436 // ------------------------------------------------------------------------
433 // For all requests. Set by StartRequest. 437 // For all requests. Set by StartRequest.
434 // ------------------------------------------------------------------------ 438 // ------------------------------------------------------------------------
435 StatusCallback error_callback; 439 StatusCallback error_callback;
436 base::TimeTicks start_time; 440 base::Time start_time;
441 base::TimeTicks start_time_ticks;
437 ServiceWorkerMetrics::EventType event_type; 442 ServiceWorkerMetrics::EventType event_type;
438 443
439 // ------------------------------------------------------------------------- 444 // -------------------------------------------------------------------------
440 // For Mojo requests. 445 // For Mojo requests.
441 // ------------------------------------------------------------------------- 446 // -------------------------------------------------------------------------
442 // Name of the mojo service this request is associated with. Used to call 447 // Name of the mojo service this request is associated with. Used to call
443 // the callback when a connection closes with outstanding requests. Compared 448 // the callback when a connection closes with outstanding requests. Compared
444 // as pointer, so should only contain static strings. Typically this would 449 // as pointer, so should only contain static strings. Typically this would
445 // be Interface::Name_ for some mojo interface. 450 // be Interface::Name_ for some mojo interface.
446 const char* mojo_service = nullptr; 451 const char* mojo_service = nullptr;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 // Message handlers. 570 // Message handlers.
566 571
567 // This corresponds to the spec's get(id) steps. 572 // This corresponds to the spec's get(id) steps.
568 void OnGetClient(int request_id, const std::string& client_uuid); 573 void OnGetClient(int request_id, const std::string& client_uuid);
569 574
570 // This corresponds to the spec's matchAll(options) steps. 575 // This corresponds to the spec's matchAll(options) steps.
571 void OnGetClients(int request_id, 576 void OnGetClients(int request_id,
572 const ServiceWorkerClientQueryOptions& options); 577 const ServiceWorkerClientQueryOptions& options);
573 578
574 void OnSimpleEventResponse(int request_id, 579 void OnSimpleEventResponse(int request_id,
575 blink::WebServiceWorkerEventResult result); 580 blink::WebServiceWorkerEventResult result,
581 base::Time dispatch_event_time);
576 void OnOpenWindow(int request_id, GURL url); 582 void OnOpenWindow(int request_id, GURL url);
577 void OnOpenWindowFinished(int request_id, 583 void OnOpenWindowFinished(int request_id,
578 ServiceWorkerStatusCode status, 584 ServiceWorkerStatusCode status,
579 const ServiceWorkerClientInfo& client_info); 585 const ServiceWorkerClientInfo& client_info);
580 586
581 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); 587 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data);
582 void OnSetCachedMetadataFinished(int64_t callback_id, int result); 588 void OnSetCachedMetadataFinished(int64_t callback_id, int result);
583 void OnClearCachedMetadata(const GURL& url); 589 void OnClearCachedMetadata(const GURL& url);
584 void OnClearCachedMetadataFinished(int64_t callback_id, int result); 590 void OnClearCachedMetadataFinished(int64_t callback_id, int result);
585 591
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 836
831 // At this point |this| can have been deleted, so don't do anything other 837 // At this point |this| can have been deleted, so don't do anything other
832 // than returning. 838 // than returning.
833 839
834 return true; 840 return true;
835 } 841 }
836 842
837 } // namespace content 843 } // namespace content
838 844
839 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 845 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698