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

Side by Side Diff: content/browser/push_messaging/push_messaging_router.h

Issue 1579413004: Move push event dispatching out of ServiceWorkerVersion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hopefully correct tests 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
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_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_ 5 #ifndef CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_
6 #define CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_ 6 #define CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "content/common/service_worker/service_worker_status_code.h" 13 #include "content/common/service_worker/service_worker_status_code.h"
14 #include "content/public/common/push_messaging_status.h" 14 #include "content/public/common/push_messaging_status.h"
15 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerEventResult.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 class BrowserContext; 20 class BrowserContext;
20 class ServiceWorkerContextWrapper; 21 class ServiceWorkerContextWrapper;
21 class ServiceWorkerRegistration; 22 class ServiceWorkerRegistration;
23 class ServiceWorkerVersion;
22 24
23 class PushMessagingRouter { 25 class PushMessagingRouter {
24 public: 26 public:
25 typedef base::Callback<void(PushDeliveryStatus)> DeliverMessageCallback; 27 typedef base::Callback<void(PushDeliveryStatus)> DeliverMessageCallback;
26 28
27 // Delivers a push message with |data| to the Service Worker identified by 29 // Delivers a push message with |data| to the Service Worker identified by
28 // |origin| and |service_worker_registration_id|. Must be called on the UI 30 // |origin| and |service_worker_registration_id|. Must be called on the UI
29 // thread. 31 // thread.
30 static void DeliverMessage( 32 static void DeliverMessage(
31 BrowserContext* browser_context, 33 BrowserContext* browser_context,
(...skipping 15 matching lines...) Expand all
47 // If a registration was successfully retrieved, dispatches a push event with 49 // If a registration was successfully retrieved, dispatches a push event with
48 // |data| on the Service Worker identified by |service_worker_registration|. 50 // |data| on the Service Worker identified by |service_worker_registration|.
49 // Must be called on the IO thread. 51 // Must be called on the IO thread.
50 static void FindServiceWorkerRegistrationCallback( 52 static void FindServiceWorkerRegistrationCallback(
51 const std::string& data, 53 const std::string& data,
52 const DeliverMessageCallback& deliver_message_callback, 54 const DeliverMessageCallback& deliver_message_callback,
53 ServiceWorkerStatusCode service_worker_status, 55 ServiceWorkerStatusCode service_worker_status,
54 const scoped_refptr<ServiceWorkerRegistration>& 56 const scoped_refptr<ServiceWorkerRegistration>&
55 service_worker_registration); 57 service_worker_registration);
56 58
57 // Gets called asynchronously after the Service Worker has dispatched the push 59 // Delivers a push message with |data| to a specific |service_worker|. Must be
58 // event. Must be called on the IO thread. 60 // called on the IO thread, with a the worker running.
johnme 2016/01/22 14:35:37 s/a the/the/
Marijn Kruisselbrink 2016/01/23 00:02:19 Done
59 static void DeliverMessageEnd( 61 static void DeliverMessageToWorker(
62 const scoped_refptr<ServiceWorkerVersion>& service_worker,
63 const scoped_refptr<ServiceWorkerRegistration>&
64 service_worker_registration,
65 const std::string& data,
66 const DeliverMessageCallback& deliver_message_callback);
67
68 // Gets called asynchronously if dispatching a push event has failed. Must be
69 // called on the IO thread.
70 static void DeliverMessageFailed(
60 const DeliverMessageCallback& deliver_message_callback, 71 const DeliverMessageCallback& deliver_message_callback,
61 const scoped_refptr<ServiceWorkerRegistration>& 72 const scoped_refptr<ServiceWorkerRegistration>&
62 service_worker_registration, 73 service_worker_registration,
63 ServiceWorkerStatusCode service_worker_status); 74 ServiceWorkerStatusCode service_worker_status);
64 75
76 // Gets called asynchronously after the Service Worker has dispatched the push
77 // event with the result from the renderer. Must be called on the IO thread.
78 static void DeliverMessageFinished(
79 const DeliverMessageCallback& deliver_message_callback,
80 const scoped_refptr<ServiceWorkerVersion>& service_worker,
81 const scoped_refptr<ServiceWorkerRegistration>&
82 service_worker_registration,
83 int request_id,
84 blink::WebServiceWorkerEventResult result);
85
65 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter); 86 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter);
66 }; 87 };
67 88
68 } // namespace content 89 } // namespace content
69 90
70 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_ 91 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698