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.
4
5#ifndef WebServiceWorkerRegistrationProxy_h
6#define WebServiceWorkerRegistrationProxy_h
7
8#if INSIDE_BLINK
9#include "platform/heap/Handle.h"
10#endif
11#include "public/platform/WebCommon.h"
12
13namespace blink {
14
15class ServiceWorkerRegistration;
16class WebServiceWorker;
17
18// A proxy interface, passed via WebServiceWorkerRegistration.setProxy() from
19// blink to the embedder, to talk to the ServiceWorkerRegistration object from
20// embedder.
21class WebServiceWorkerRegistrationProxy {
22public:
23    WebServiceWorkerRegistrationProxy() : m_private(0) { }
24    virtual ~WebServiceWorkerRegistrationProxy() { }
25
26    // Notifies that the registration entered the installation process.
27    // The installing worker should be accessible via
28    // WebServiceWorkerRegistration.installing.
29    virtual void dispatchUpdateFoundEvent() = 0;
30
31    virtual void setInstalling(WebServiceWorker*) = 0;
32    virtual void setWaiting(WebServiceWorker*) = 0;
33    virtual void setActive(WebServiceWorker*) = 0;
34
35#if INSIDE_BLINK
36    BLINK_PLATFORM_EXPORT WebServiceWorkerRegistrationProxy(ServiceWorkerRegistration*);
37    BLINK_PLATFORM_EXPORT operator ServiceWorkerRegistration*() const;
38#endif
39
40protected:
41#if INSIDE_BLINK
42    // This is a back pointer to |this| object.
43    // The ServiceWorkerRegistration inherits from this WebServiceWorkerRegistrationProxy.
44    GC_PLUGIN_IGNORE("crbug.com/410257")
45#endif
46    ServiceWorkerRegistration* m_private;
47};
48
49} // namespace blink
50
51#endif // WebServiceWorkerRegistrationProxy_h
52