15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2013 Google Inc. All rights reserved.
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions are
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * met:
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * in the documentation and/or other materials provided with the
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * distribution.
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * contributors may be used to endorse or promote products derived from
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * this software without specific prior written permission.
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3106f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)#ifndef WebServiceWorker_h
3206f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)#define WebServiceWorker_h
33926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "WebCommon.h"
3507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "WebMessagePortChannel.h"
366f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch#include "WebServiceWorkerState.h"
376f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch#include "WebString.h"
386f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch#include "WebURL.h"
3907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "WebVector.h"
4007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch
4151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink {
429bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)
436f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdochclass WebServiceWorkerProxy;
4407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochtypedef WebVector<class WebMessagePortChannel*> WebMessagePortChannelArray;
4507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch
4606f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)class WebServiceWorker {
4707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochpublic:
4807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    virtual ~WebServiceWorker() { }
49926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
506f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    // Sets ServiceWorkerProxy, with which callee can start making upcalls
516f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    // to the ServiceWorker object via the client. This doesn't pass the
526f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    // ownership to the callee, and the proxy's lifetime is same as that of
536f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    // WebServiceWorker.
546f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    virtual void setProxy(WebServiceWorkerProxy*) { }
55f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)    virtual WebServiceWorkerProxy* proxy() { return 0; }
566f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch
57f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    // Called by this worker's ServiceWorkerProxy when it has become ready or
58f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    // not ready for state change notifications.
59f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu    virtual void proxyReadyChanged() { }
60f91f5fa1608c2cdd9af1842fb5dadbe78275be2aBo Liu
616f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    virtual WebURL scope() const { return WebURL(); }
626f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    virtual WebURL url() const { return WebURL(); }
636f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch    virtual WebServiceWorkerState state() const { return WebServiceWorkerStateUnknown; }
646f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch
6507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    // Callee receives ownership of the passed vector.
6607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    // FIXME: Blob refs should be passed to maintain ref counts. crbug.com/351753
6707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    virtual void postMessage(const WebString&, WebMessagePortChannelArray*) { BLINK_ASSERT_NOT_REACHED(); }
685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)};
699bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)
709bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)}
719bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)
7206f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)#endif // WebServiceWorker_h
73