OLD | NEW |
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 Loading... |
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 |
| 59 // Delivers a push message with |data| to a specific |service_worker|. Must be |
| 60 // called on the IO thread, with the the worker running. |
| 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 |
57 // Gets called asynchronously after the Service Worker has dispatched the push | 68 // Gets called asynchronously after the Service Worker has dispatched the push |
58 // event. Must be called on the IO thread. | 69 // event. Must be called on the IO thread. |
59 static void DeliverMessageEnd( | 70 static void DeliverMessageEnd( |
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 |
65 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter); | 76 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter); |
66 }; | 77 }; |
67 | 78 |
68 } // namespace content | 79 } // namespace content |
69 | 80 |
70 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_ | 81 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_ |
OLD | NEW |