• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 WebCommonWorkerClient_h
32 #define WebCommonWorkerClient_h
33 
34 #include "WebCommon.h"
35 #include "WebFileSystem.h"
36 
37 namespace WebKit {
38 
39 class WebApplicationCacheHost;
40 class WebApplicationCacheHostClient;
41 class WebFrame;
42 class WebNotificationPresenter;
43 class WebString;
44 class WebWorker;
45 class WebWorkerClient;
46 
47 // Provides an interface back to the in-page script object for a worker.
48 // This interface contains common APIs used by both shared and dedicated
49 // workers.
50 // All functions are expected to be called back on the thread that created
51 // the Worker object, unless noted.
52 class WebCommonWorkerClient {
53 public:
54     virtual void postExceptionToWorkerObject(
55         const WebString& errorString, int lineNumber,
56         const WebString& sourceURL) = 0;
57 
58     // FIXME: the below is for compatibility only and should be
59     // removed once Chromium is updated to remove message
60     // destination parameter <http://webkit.org/b/37155>.
61     virtual void postConsoleMessageToWorkerObject(int, int sourceIdentifier, int messageType, int messageLevel,
62                                                   const WebString& message, int lineNumber, const WebString& sourceURL) = 0;
63 
postConsoleMessageToWorkerObject(int sourceIdentifier,int messageType,int messageLevel,const WebString & message,int lineNumber,const WebString & sourceURL)64     virtual void postConsoleMessageToWorkerObject(int sourceIdentifier, int messageType, int messageLevel,
65                                                   const WebString& message, int lineNumber, const WebString& sourceURL)
66     {
67         postConsoleMessageToWorkerObject(0, sourceIdentifier, messageType, messageLevel,
68                                          message, lineNumber, sourceURL);
69     }
70 
71     virtual void workerContextClosed() = 0;
72     virtual void workerContextDestroyed() = 0;
73 
74     // Returns the notification presenter for this worker context.  Pointer
75     // is owned by the object implementing WebCommonWorkerClient.
76     virtual WebNotificationPresenter* notificationPresenter() = 0;
77 
78     // This can be called on any thread to create a nested WebWorker.
79     // WebSharedWorkers are not instantiated via this API - instead
80     // they are created via the WebSharedWorkerRepository.
81     virtual WebWorker* createWorker(WebWorkerClient* client) = 0;
82 
83     // Called on the main webkit thread in the worker process during initialization.
84     virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) = 0;
85 
86     // Called on the main webkit thread before opening a web database.
87     virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) = 0;
88 
89     // Called on the main webkit thread before opening a file system.
openFileSystem(WebFileSystem::Type,long long size,bool create,WebFileSystemCallbacks *)90     virtual void openFileSystem(WebFileSystem::Type, long long size, bool create, WebFileSystemCallbacks*)
91     {
92         WEBKIT_ASSERT_NOT_REACHED();
93     }
94 
95 protected:
~WebCommonWorkerClient()96     ~WebCommonWorkerClient() { }
97 };
98 
99 } // namespace WebKit
100 
101 #endif
102