summaryrefslogtreecommitdiffstats
path: root/content/browser/push_messaging/push_messaging_router.h
diff options
context:
space:
mode:
authormvanouwerkerk <mvanouwerkerk@chromium.org>2014-11-07 09:30:15 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-07 17:30:43 +0000
commit17205eaf463fc42099bcd8770757e01e65e470d9 (patch)
tree50053dfb70db6a1294641b79490ce1f4796b223d /content/browser/push_messaging/push_messaging_router.h
parentf7a2e0c4baa4c8029a87b0264abfae8b16865dac (diff)
downloadchromium_src-17205eaf463fc42099bcd8770757e01e65e470d9.zip
chromium_src-17205eaf463fc42099bcd8770757e01e65e470d9.tar.gz
chromium_src-17205eaf463fc42099bcd8770757e01e65e470d9.tar.bz2
Move Push API files to content/browser/push_messaging/
Add mvanouwerkerk as owner. This is a mechanical move using tools/git/move_source_file.py Review URL: https://codereview.chromium.org/703043003 Cr-Commit-Position: refs/heads/master@{#303249}
Diffstat (limited to 'content/browser/push_messaging/push_messaging_router.h')
-rw-r--r--content/browser/push_messaging/push_messaging_router.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/content/browser/push_messaging/push_messaging_router.h b/content/browser/push_messaging/push_messaging_router.h
new file mode 100644
index 0000000..d9f25cc
--- /dev/null
+++ b/content/browser/push_messaging/push_messaging_router.h
@@ -0,0 +1,68 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_
+#define CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "content/common/service_worker/service_worker_status_code.h"
+#include "content/public/common/push_messaging_status.h"
+#include "url/gurl.h"
+
+namespace content {
+
+class BrowserContext;
+class ServiceWorkerContextWrapper;
+class ServiceWorkerRegistration;
+
+class PushMessagingRouter {
+ public:
+ typedef base::Callback<void(PushDeliveryStatus)>
+ DeliverMessageCallback;
+
+ // Delivers a push message with |data| to the Service Worker identified by
+ // |origin| and |service_worker_registration_id|. Must be called on the UI
+ // thread.
+ static void DeliverMessage(
+ BrowserContext* browser_context,
+ const GURL& origin,
+ int64 service_worker_registration_id,
+ const std::string& data,
+ const DeliverMessageCallback& deliver_message_callback);
+
+ private:
+ // Attempts to find a Service Worker registration so that a push event can be
+ // dispatched. Must be called on the IO thread.
+ static void FindServiceWorkerRegistration(
+ const GURL& origin,
+ int64 service_worker_registration_id,
+ const std::string& data,
+ const DeliverMessageCallback& deliver_message_callback,
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
+
+ // 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.
+ static void FindServiceWorkerRegistrationCallback(
+ const std::string& data,
+ const DeliverMessageCallback& deliver_message_callback,
+ ServiceWorkerStatusCode service_worker_status,
+ const scoped_refptr<ServiceWorkerRegistration>&
+ service_worker_registration);
+
+ // Gets called asynchronously after the Service Worker has dispatched the push
+ // event. Must be called on the IO thread.
+ static void DeliverMessageEnd(
+ const DeliverMessageCallback& deliver_message_callback,
+ const scoped_refptr<ServiceWorkerRegistration>&
+ service_worker_registration,
+ ServiceWorkerStatusCode service_worker_status);
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_ROUTER_H_