Chromium Code Reviews| 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 "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 class BrowserContext; | 19 class BrowserContext; |
| 20 class ServiceWorkerContextWrapper; | 20 class ServiceWorkerContextWrapper; |
| 21 class ServiceWorkerRegistration; | 21 class ServiceWorkerRegistration; |
| 22 class ServiceWorkerVersion; | |
| 22 | 23 |
| 23 class PushMessagingRouter { | 24 class PushMessagingRouter { |
| 24 public: | 25 public: |
| 25 typedef base::Callback<void(PushDeliveryStatus)> DeliverMessageCallback; | 26 typedef base::Callback<void(PushDeliveryStatus)> DeliverMessageCallback; |
| 26 | 27 |
| 27 // Delivers a push message with |data| to the Service Worker identified by | 28 // 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 | 29 // |origin| and |service_worker_registration_id|. Must be called on the UI |
| 29 // thread. | 30 // thread. |
| 30 static void DeliverMessage( | 31 static void DeliverMessage( |
| 31 BrowserContext* browser_context, | 32 BrowserContext* browser_context, |
| 32 const GURL& origin, | 33 const GURL& origin, |
| 33 int64_t service_worker_registration_id, | 34 int64_t service_worker_registration_id, |
| 34 const std::string& data, | 35 const std::string& data, |
| 35 const DeliverMessageCallback& deliver_message_callback); | 36 const DeliverMessageCallback& deliver_message_callback); |
| 36 | 37 |
| 38 // Delivers a push message with |data| to a specific |service_worker|. Must be | |
| 39 // called on the IO thread. | |
| 40 static void DeliverMessageToWorker( | |
|
johnme
2016/01/18 19:06:19
It's kind of messy that there are now two public m
Marijn Kruisselbrink
2016/01/20 01:06:31
The only reason there is a second public method is
Peter Beverloo
2016/01/20 11:48:40
How common is the fetch() paradigm? As far as I'm
Peter Beverloo
2016/01/20 11:48:40
Let's kill the button? I don't think anybody uses
| |
| 41 const scoped_refptr<ServiceWorkerVersion>& service_worker, | |
| 42 const std::string& data, | |
| 43 const base::Callback<void(ServiceWorkerStatusCode)>& callback); | |
| 44 | |
| 37 private: | 45 private: |
| 38 // Attempts to find a Service Worker registration so that a push event can be | 46 // Attempts to find a Service Worker registration so that a push event can be |
| 39 // dispatched. Must be called on the IO thread. | 47 // dispatched. Must be called on the IO thread. |
| 40 static void FindServiceWorkerRegistration( | 48 static void FindServiceWorkerRegistration( |
| 41 const GURL& origin, | 49 const GURL& origin, |
| 42 int64_t service_worker_registration_id, | 50 int64_t service_worker_registration_id, |
| 43 const std::string& data, | 51 const std::string& data, |
| 44 const DeliverMessageCallback& deliver_message_callback, | 52 const DeliverMessageCallback& deliver_message_callback, |
| 45 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | 53 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); |
| 46 | 54 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 61 const scoped_refptr<ServiceWorkerRegistration>& | 69 const scoped_refptr<ServiceWorkerRegistration>& |
| 62 service_worker_registration, | 70 service_worker_registration, |
| 63 ServiceWorkerStatusCode service_worker_status); | 71 ServiceWorkerStatusCode service_worker_status); |
| 64 | 72 |
| 65 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter); | 73 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter); |
| 66 }; | 74 }; |
| 67 | 75 |
| 68 } // namespace content | 76 } // namespace content |
| 69 | 77 |
| 70 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_ | 78 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_ |
| OLD | NEW |