1/* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#ifndef WebSharedWorkerClient_h 32#define WebSharedWorkerClient_h 33 34#include "../platform/WebMessagePortChannel.h" 35#include "WebCommonWorkerClient.h" 36 37namespace WebKit { 38 39class WebNotificationPresenter; 40class WebString; 41class WebWorker; 42 43// Provides an interface back to the in-page script object for a worker. 44// All functions are expected to be called back on the thread that created 45// the Worker object, unless noted. 46class WebSharedWorkerClient : public WebCommonWorkerClient { 47public: 48 virtual void postMessageToWorkerObject( 49 const WebString&, 50 const WebMessagePortChannelArray&) = 0; 51 52 virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0; 53 virtual void reportPendingActivity(bool hasPendingActivity) = 0; 54 55 virtual void postExceptionToWorkerObject( 56 const WebString& errorString, int lineNumber, 57 const WebString& sourceURL) = 0; 58 59 // FIXME: the two below are for compatibility only and should be removed 60 // once Chromium is updated to remove message destination parameter 61 // <http://webkit.org/b/37155> and the message type parameter 62 // <http://webkit.org/b/66371>. 63 virtual void postConsoleMessageToWorkerObject(int, int sourceIdentifier, int, int messageLevel, 64 const WebString& message, int lineNumber, const WebString& sourceURL) = 0; 65 virtual void postConsoleMessageToWorkerObject(int sourceIdentifier, int, int messageLevel, 66 const WebString& message, int lineNumber, const WebString& sourceURL) 67 { 68 postConsoleMessageToWorkerObject(0, sourceIdentifier, 0, messageLevel, 69 message, lineNumber, sourceURL); 70 } 71 72 virtual void postConsoleMessageToWorkerObject(int sourceIdentifier, int messageLevel, 73 const WebString& message, int lineNumber, const WebString& sourceURL) 74 { 75 postConsoleMessageToWorkerObject(0, sourceIdentifier, messageLevel, 76 message, lineNumber, sourceURL); 77 } 78 79 virtual void workerContextClosed() = 0; 80 virtual void workerContextDestroyed() = 0; 81 82 // Returns the notification presenter for this worker context. Pointer 83 // is owned by the object implementing WebCommonWorkerClient. 84 virtual WebNotificationPresenter* notificationPresenter() = 0; 85 86 // Called on the main webkit thread in the worker process during initialization. 87 virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) = 0; 88 89 virtual void dispatchDevToolsMessage(const WebString&) { } 90 virtual void saveDevToolsAgentState(const WebString&) { } 91 92protected: 93 ~WebSharedWorkerClient() { } 94}; 95 96} // namespace WebKit 97 98#endif 99