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

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: Address comments Created 4 years, 10 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 "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 struct PushEventPayload;
20 class ServiceWorkerContextWrapper; 21 class ServiceWorkerContextWrapper;
21 class ServiceWorkerRegistration; 22 class ServiceWorkerRegistration;
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 content::PushEventPayload& payload,
Peter Beverloo 2016/01/26 12:35:18 s/content::// Elsewhere in this file too.
harkness 2016/01/26 14:49:20 Done.
35 const DeliverMessageCallback& deliver_message_callback); 36 const DeliverMessageCallback& deliver_message_callback);
36 37
37 private: 38 private:
38 // Attempts to find a Service Worker registration so that a push event can be 39 // Attempts to find a Service Worker registration so that a push event can be
39 // dispatched. Must be called on the IO thread. 40 // dispatched. Must be called on the IO thread.
40 static void FindServiceWorkerRegistration( 41 static void FindServiceWorkerRegistration(
41 const GURL& origin, 42 const GURL& origin,
42 int64_t service_worker_registration_id, 43 int64_t service_worker_registration_id,
43 const std::string& data, 44 const content::PushEventPayload& payload,
44 const DeliverMessageCallback& deliver_message_callback, 45 const DeliverMessageCallback& deliver_message_callback,
45 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); 46 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
46 47
47 // If a registration was successfully retrieved, dispatches a push event with 48 // If a registration was successfully retrieved, dispatches a push event with
48 // |data| on the Service Worker identified by |service_worker_registration|. 49 // |data| on the Service Worker identified by |service_worker_registration|.
49 // Must be called on the IO thread. 50 // Must be called on the IO thread.
50 static void FindServiceWorkerRegistrationCallback( 51 static void FindServiceWorkerRegistrationCallback(
51 const std::string& data, 52 const content::PushEventPayload& payload,
52 const DeliverMessageCallback& deliver_message_callback, 53 const DeliverMessageCallback& deliver_message_callback,
53 ServiceWorkerStatusCode service_worker_status, 54 ServiceWorkerStatusCode service_worker_status,
54 const scoped_refptr<ServiceWorkerRegistration>& 55 const scoped_refptr<ServiceWorkerRegistration>&
55 service_worker_registration); 56 service_worker_registration);
56 57
57 // Gets called asynchronously after the Service Worker has dispatched the push 58 // Gets called asynchronously after the Service Worker has dispatched the push
58 // event. Must be called on the IO thread. 59 // event. Must be called on the IO thread.
59 static void DeliverMessageEnd( 60 static void DeliverMessageEnd(
60 const DeliverMessageCallback& deliver_message_callback, 61 const DeliverMessageCallback& deliver_message_callback,
61 const scoped_refptr<ServiceWorkerRegistration>& 62 const scoped_refptr<ServiceWorkerRegistration>&
62 service_worker_registration, 63 service_worker_registration,
63 ServiceWorkerStatusCode service_worker_status); 64 ServiceWorkerStatusCode service_worker_status);
64 65
65 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter); 66 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter);
66 }; 67 };
67 68
68 } // namespace content 69 } // namespace content
69 70
70 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_ 71 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698