Chromium Code Reviews| Index: content/browser/push_messaging_router_impl.h |
| diff --git a/content/browser/push_messaging_router_impl.h b/content/browser/push_messaging_router_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0572464258d12d98b5fa207cd2327f9ff6197a36 |
| --- /dev/null |
| +++ b/content/browser/push_messaging_router_impl.h |
| @@ -0,0 +1,73 @@ |
| +// 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_ROUTER_IMPL_H_ |
| +#define CONTENT_BROWSER_PUSH_MESSAGING_ROUTER_IMPL_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/browser/push_messaging_router.h" |
| + |
| +namespace content { |
| + |
| +class BrowserContext; |
| +class ServiceWorkerContextWrapper; |
| +class ServiceWorkerRegistration; |
| +struct PushMessagingApplicationId; |
| + |
| +class PushMessagingRouterImpl : public PushMessagingRouter { |
| + public: |
| + // PushMessagingRouter implementation. |
| + virtual void SendMessage( |
| + const PushMessagingApplicationId& application_id, |
| + const std::string& data, |
| + const SendMessageCallback& send_message_callback) OVERRIDE; |
| + |
| + explicit PushMessagingRouterImpl(BrowserContext* browser_context); |
|
johnme
2014/07/23 14:25:23
I'd suggest to either make this constructor privat
Michael van Ouwerkerk
2014/07/23 16:57:52
The PushMessagingRouterImpl constructor does need
|
| + virtual ~PushMessagingRouterImpl(); |
| + |
| + private: |
| + // Attempts to find a Service Worker registration for |application_id| so that |
| + // a message can be dispatched. Must be called on the IO thread. |
| + void FindServiceWorkerRegistration( |
| + const PushMessagingApplicationId& application_id, |
| + const std::string& data, |
| + const SendMessageCallback& send_message_callback, |
| + scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); |
| + |
| + // Sends the message if a registration was found. Must be called on the IO |
| + // thread. |
| + void FindServiceWorkerRegistrationCallback( |
| + const PushMessagingApplicationId& application_id, |
| + const std::string& data, |
| + const SendMessageCallback& send_message_callback, |
| + ServiceWorkerStatusCode service_worker_status, |
| + const scoped_refptr<ServiceWorkerRegistration>& |
| + service_worker_registration); |
| + |
| + // Sends a push message with |data| to the Service Worker identified by |
| + // |service_worker_registration|. Must be called on the IO thread. |
| + void DoSendMessage(const std::string& data, |
| + const SendMessageCallback& send_message_callback, |
| + 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. |
| + void SendMessageEnd(const SendMessageCallback& send_message_callback, |
| + const scoped_refptr<ServiceWorkerRegistration>& |
| + service_worker_registration, |
| + ServiceWorkerStatusCode service_worker_status); |
| + |
| + BrowserContext* browser_context_; // It indirectly owns this. |
| + |
| + base::WeakPtrFactory<PushMessagingRouterImpl> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PushMessagingRouterImpl); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_PUSH_MESSAGING_ROUTER_IMPL_H_ |