Implement SSLKEYLOGFILE for OpenSSL.
[chromium-blink-merge.git] / content / browser / push_messaging_router.h
blobf59a2ee552f5ea9e13246cf9b82b99421aa0e8e7
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_PUSH_MESSAGING_ROUTER_H_
6 #define CONTENT_BROWSER_PUSH_MESSAGING_ROUTER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/common/service_worker/service_worker_status_code.h"
11 #include "content/public/common/push_messaging_status.h"
12 #include "url/gurl.h"
14 namespace content {
16 class BrowserContext;
17 class ServiceWorkerContextWrapper;
18 class ServiceWorkerRegistration;
20 class PushMessagingRouter {
21 public:
22 typedef base::Callback<void(PushMessagingStatus /* push_messaging_status */)>
23 DeliverMessageCallback;
25 // Delivers a push message with |data| to the Service Worker identified by
26 // |origin| and |service_worker_registration_id|. Must be called on the UI
27 // thread.
28 static void DeliverMessage(
29 BrowserContext* browser_context,
30 const GURL& origin,
31 int64 service_worker_registration_id,
32 const std::string& data,
33 const DeliverMessageCallback& deliver_message_callback);
35 private:
36 // Attempts to find a Service Worker registration so that a push event can be
37 // dispatched. Must be called on the IO thread.
38 static void FindServiceWorkerRegistration(
39 const GURL& origin,
40 int64 service_worker_registration_id,
41 const std::string& data,
42 const DeliverMessageCallback& deliver_message_callback,
43 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
45 // If a registration was successfully retrieved, dispatches a push event with
46 // |data| on the Service Worker identified by |service_worker_registration|.
47 // Must be called on the IO thread.
48 static void FindServiceWorkerRegistrationCallback(
49 const std::string& data,
50 const DeliverMessageCallback& deliver_message_callback,
51 ServiceWorkerStatusCode service_worker_status,
52 const scoped_refptr<ServiceWorkerRegistration>&
53 service_worker_registration);
55 // Gets called asynchronously after the Service Worker has dispatched the push
56 // event. Must be called on the IO thread.
57 static void DeliverMessageEnd(
58 const DeliverMessageCallback& deliver_message_callback,
59 const scoped_refptr<ServiceWorkerRegistration>&
60 service_worker_registration,
61 ServiceWorkerStatusCode service_worker_status);
63 DISALLOW_IMPLICIT_CONSTRUCTORS(PushMessagingRouter);
66 } // namespace content
68 #endif // CONTENT_BROWSER_PUSH_MESSAGING_ROUTER_H_