Commit 208c583c authored by Viviane Yang's avatar Viviane Yang Committed by Commit Bot

[Push] Separation of service worker and message delivery methods.

Separate methods for finding service_worker_version (can be reused for
other events) and message delivery functions.
This CL prepares the PushMessagingRouter class to support
PushSubscriptionChange events.

Additionally, |service_worker_context| is removed from DeliverMessageEnd
since it is not used.


Bug: 1107744
Change-Id: Iad371fdb68d50cc0c0dc73a1a1661613e18753da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2308710Reviewed-by: default avatarRayan Kanso <rayankans@chromium.org>
Reviewed-by: default avatarRichard Knoll <knollr@chromium.org>
Commit-Queue: Viviane Yang <viviy@google.com>
Cr-Commit-Position: refs/heads/master@{#790824}
parent 47194c06
...@@ -24,8 +24,6 @@ namespace content { ...@@ -24,8 +24,6 @@ namespace content {
class BrowserContext; class BrowserContext;
class DevToolsBackgroundServicesContextImpl; class DevToolsBackgroundServicesContextImpl;
class ServiceWorkerContextWrapper;
class ServiceWorkerRegistration;
class ServiceWorkerVersion; class ServiceWorkerVersion;
class PushMessagingRouter { class PushMessagingRouter {
...@@ -33,7 +31,7 @@ class PushMessagingRouter { ...@@ -33,7 +31,7 @@ class PushMessagingRouter {
using DeliverMessageCallback = using DeliverMessageCallback =
base::OnceCallback<void(blink::mojom::PushDeliveryStatus)>; base::OnceCallback<void(blink::mojom::PushDeliveryStatus)>;
// Delivers a push message with |data| to the Service Worker identified by // Delivers a push message with |payload| to the Service Worker identified by
// |origin| and |service_worker_registration_id|. Must be called on the UI // |origin| and |service_worker_registration_id|. Must be called on the UI
// thread. // thread.
static void DeliverMessage(BrowserContext* browser_context, static void DeliverMessage(BrowserContext* browser_context,
...@@ -44,44 +42,20 @@ class PushMessagingRouter { ...@@ -44,44 +42,20 @@ class PushMessagingRouter {
DeliverMessageCallback deliver_message_callback); DeliverMessageCallback deliver_message_callback);
private: private:
// Attempts to find a Service Worker registration so that a push event can be // Delivers a push message with |payload| to a specific |service_worker|.
// dispatched. Must be called on the IO thread.
static void FindServiceWorkerRegistration(
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const GURL& origin,
int64_t service_worker_registration_id,
const std::string& message_id,
base::Optional<std::string> payload,
DeliverMessageCallback deliver_message_callback);
// If a registration was successfully retrieved, dispatches a push event with
// |data| on the Service Worker identified by |service_worker_registration|.
// Must be called on the IO thread. // Must be called on the IO thread.
static void FindServiceWorkerRegistrationCallback( static void DeliverMessageToWorker(
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const std::string& message_id, const std::string& message_id,
base::Optional<std::string> payload, base::Optional<std::string> payload,
DeliverMessageCallback deliver_message_callback, DeliverMessageCallback deliver_message_callback,
blink::ServiceWorkerStatusCode service_worker_status,
scoped_refptr<ServiceWorkerRegistration> service_worker_registration);
// Delivers a push message with |data| to a specific |service_worker|.
// Must be called on the IO thread.
static void DeliverMessageToWorker(
scoped_refptr<ServiceWorkerVersion> service_worker, scoped_refptr<ServiceWorkerVersion> service_worker,
scoped_refptr<ServiceWorkerRegistration> service_worker_registration,
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context, scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const std::string& message_id, blink::ServiceWorkerStatusCode status);
base::Optional<std::string> payload,
DeliverMessageCallback deliver_message_callback,
blink::ServiceWorkerStatusCode start_worker_status);
// Gets called asynchronously after the Service Worker has dispatched the push // Gets called asynchronously after the Service Worker has dispatched the push
// event. Must be called on the IO thread. // event. Must be called on the IO thread.
static void DeliverMessageEnd( static void DeliverMessageEnd(
scoped_refptr<ServiceWorkerVersion> service_worker, scoped_refptr<ServiceWorkerVersion> service_worker,
scoped_refptr<ServiceWorkerRegistration> service_worker_registration,
scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context, scoped_refptr<DevToolsBackgroundServicesContextImpl> devtools_context,
const std::string& message_id, const std::string& message_id,
DeliverMessageCallback deliver_message_callback, DeliverMessageCallback deliver_message_callback,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment