16f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 26f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch// Use of this source code is governed by a BSD-style license that can be 36f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch// found in the LICENSE file. 46f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch 56f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch#ifndef WebServiceWorkerProxy_h 66f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch#define WebServiceWorkerProxy_h 76f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch 8f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)#include "WebCommon.h" 9f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) 106f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdochnamespace blink { 116f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch 12e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)class ServiceWorker; 13e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles) 146f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch// A proxy interface, passed via WebServiceWorker.setProxy() from blink to 156f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch// the embedder, to talk to the ServiceWorker object from embedder. 166f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdochclass WebServiceWorkerProxy { 176f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdochpublic: 18f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) WebServiceWorkerProxy() : m_private(0) { } 19f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) virtual ~WebServiceWorkerProxy() { } 20f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) 21f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // Returns true if the proxy is ready to be notified of service worker state 22f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // changes. It may not be if it's waiting for the registration promise to 23f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // resolve, while the browser side has registered and is proceeding to 24f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // install and activate the worker. 25f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu virtual bool isReady() = 0; 26f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu 27f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // Notifies the proxy that the service worker state changed. The new state 28f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu // should be accessible via WebServiceWorker.state(). 296f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch virtual void dispatchStateChangeEvent() = 0; 30f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) 31f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)#if INSIDE_BLINK 32e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles) BLINK_PLATFORM_EXPORT WebServiceWorkerProxy(ServiceWorker*); 33e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles) BLINK_PLATFORM_EXPORT ServiceWorker* unwrap() const; 34f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)#endif 35f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) 36f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)protected: 37e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles) ServiceWorker* m_private; 386f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch}; 396f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch 406f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch} // namespace blink 416f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch 426f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch#endif // WebServiceWorkerProxy_h 43