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

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

Issue 1636483002: Update the PushEvent to have a nullable PushMessageData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review comments and include 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 "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor kerEventResult.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 class BrowserContext; 20 class BrowserContext;
21 struct PushEventPayload;
21 class ServiceWorkerContextWrapper; 22 class ServiceWorkerContextWrapper;
22 class ServiceWorkerRegistration; 23 class ServiceWorkerRegistration;
23 class ServiceWorkerVersion; 24 class ServiceWorkerVersion;
24 25
25 class PushMessagingRouter { 26 class PushMessagingRouter {
26 public: 27 public:
27 typedef base::Callback<void(PushDeliveryStatus)> DeliverMessageCallback; 28 typedef base::Callback<void(PushDeliveryStatus)> DeliverMessageCallback;
28 29
29 // Delivers a push message with |data| to the Service Worker identified by 30 // Delivers a push message with |data| to the Service Worker identified by
30 // |origin| and |service_worker_registration_id|. Must be called on the UI 31 // |origin| and |service_worker_registration_id|. Must be called on the UI
31 // thread. 32 // thread.
32 static void DeliverMessage( 33 static void DeliverMessage(
33 BrowserContext* browser_context, 34 BrowserContext* browser_context,
34 const GURL& origin, 35 const GURL& origin,
35 int64_t service_worker_registration_id, 36 int64_t service_worker_registration_id,
36 const std::string& data, 37 const PushEventPayload& payload,
37 const DeliverMessageCallback& deliver_message_callback); 38 const DeliverMessageCallback& deliver_message_callback);
38 39
39 private: 40 private:
40 // Attempts to find a Service Worker registration so that a push event can be 41 // Attempts to find a Service Worker registration so that a push event can be
41 // dispatched. Must be called on the IO thread. 42 // dispatched. Must be called on the IO thread.
42 static void FindServiceWorkerRegistration( 43 static void FindServiceWorkerRegistration(
43 const GURL& origin, 44 const GURL& origin,
44 int64_t service_worker_registration_id, 45 int64_t service_worker_registration_id,
45 const std::string& data, 46 const PushEventPayload& payload,
46 const DeliverMessageCallback& deliver_message_callback, 47 const DeliverMessageCallback& deliver_message_callback,
47 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); 48 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
48 49
49 // If a registration was successfully retrieved, dispatches a push event with 50 // If a registration was successfully retrieved, dispatches a push event with
50 // |data| on the Service Worker identified by |service_worker_registration|. 51 // |data| on the Service Worker identified by |service_worker_registration|.
51 // Must be called on the IO thread. 52 // Must be called on the IO thread.
52 static void FindServiceWorkerRegistrationCallback( 53 static void FindServiceWorkerRegistrationCallback(
53 const std::string& data, 54 const PushEventPayload& payload,
54 const DeliverMessageCallback& deliver_message_callback, 55 const DeliverMessageCallback& deliver_message_callback,
55 ServiceWorkerStatusCode service_worker_status, 56 ServiceWorkerStatusCode service_worker_status,
56 const scoped_refptr<ServiceWorkerRegistration>& 57 const scoped_refptr<ServiceWorkerRegistration>&
57 service_worker_registration); 58 service_worker_registration);
58 59
59 // Delivers a push message with |data| to a specific |service_worker|. Must be 60 // 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 // called on the IO thread, with the the worker running.
61 static void DeliverMessageToWorker( 62 static void DeliverMessageToWorker(
62 const scoped_refptr<ServiceWorkerVersion>& service_worker, 63 const scoped_refptr<ServiceWorkerVersion>& service_worker,
63 const scoped_refptr<ServiceWorkerRegistration>& 64 const scoped_refptr<ServiceWorkerRegistration>&
64 service_worker_registration, 65 service_worker_registration,
65 const std::string& data, 66 const PushEventPayload& payload,
66 const DeliverMessageCallback& deliver_message_callback); 67 const DeliverMessageCallback& deliver_message_callback);
67 68
68 // Gets called asynchronously after the Service Worker has dispatched the push 69 // Gets called asynchronously after the Service Worker has dispatched the push
69 // event. Must be called on the IO thread. 70 // event. Must be called on the IO thread.
70 static void DeliverMessageEnd( 71 static void DeliverMessageEnd(
71 const DeliverMessageCallback& deliver_message_callback, 72 const DeliverMessageCallback& deliver_message_callback,
72 const scoped_refptr<ServiceWorkerRegistration>& 73 const scoped_refptr<ServiceWorkerRegistration>&
73 service_worker_registration, 74 service_worker_registration,
74 ServiceWorkerStatusCode service_worker_status); 75 ServiceWorkerStatusCode service_worker_status);
75 76
76 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter); 77 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter);
77 }; 78 };
78 79
79 } // namespace content 80 } // namespace content
80 81
81 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_ 82 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/service_worker_handler.cc ('k') | content/browser/push_messaging/push_messaging_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698