| 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..886b675ffd73c6ebec4331284243dd0d9419cc7a
|
| --- /dev/null
|
| +++ b/content/browser/push_messaging_router_impl.h
|
| @@ -0,0 +1,72 @@
|
| +// 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 DeliverMessage(
|
| + const PushMessagingApplicationId& application_id,
|
| + const std::string& data,
|
| + const DeliverMessageCallback& deliver_message_callback) OVERRIDE;
|
| +
|
| + explicit PushMessagingRouterImpl(BrowserContext* browser_context);
|
| + 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 DeliverMessageCallback& deliver_message_callback,
|
| + scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
|
| +
|
| + // Delivers the message if a registration was found. Must be called on the IO
|
| + // thread.
|
| + void FindServiceWorkerRegistrationCallback(
|
| + const std::string& data,
|
| + const DeliverMessageCallback& deliver_message_callback,
|
| + ServiceWorkerStatusCode service_worker_status,
|
| + const scoped_refptr<ServiceWorkerRegistration>&
|
| + service_worker_registration);
|
| +
|
| + // Delivers a push message with |data| to the Service Worker identified by
|
| + // |service_worker_registration|. Must be called on the IO thread.
|
| + void DoDeliverMessage(const std::string& data,
|
| + const DeliverMessageCallback& deliver_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 DeliverMessageEnd(const DeliverMessageCallback& deliver_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_
|
|
|