1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_WORKER_WEBWORKERCLIENT_PROXY_H_
6 #define CONTENT_WORKER_WEBWORKERCLIENT_PROXY_H_
9 #include "base/basictypes.h"
10 #include "base/memory/weak_ptr.h"
11 #include "ipc/ipc_channel.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorkerClient.h"
16 class WebApplicationCacheHost
;
17 class WebApplicationCacheHostClient
;
21 class SharedWorkerDevToolsAgent
;
22 class WebSharedWorkerStub
;
24 // This class receives IPCs from the renderer and calls the WebCore::Worker
25 // implementation (after the data types have been converted by glue code). It
26 // is also called by the worker code and converts these function calls into
27 // IPCs that are sent to the renderer, where they're converted back to function
28 // calls by WebWorkerProxy.
29 class WebSharedWorkerClientProxy
: public WebKit::WebSharedWorkerClient
{
31 WebSharedWorkerClientProxy(int route_id
, WebSharedWorkerStub
* stub
);
32 virtual ~WebSharedWorkerClientProxy();
34 // WebSharedWorkerClient implementation.
35 virtual void postMessageToWorkerObject(
36 const WebKit::WebString
& message
,
37 const WebKit::WebMessagePortChannelArray
& channel
);
38 virtual void postExceptionToWorkerObject(
39 const WebKit::WebString
& error_message
,
41 const WebKit::WebString
& source_url
);
42 // TODO(caseq): The overload before is obsolete and is preserved for
43 // WebKit/chromium compatibility only (pure virtual is base class).
44 // Should be removed once WebKit part is updated.
45 virtual void postConsoleMessageToWorkerObject(
50 const WebKit::WebString
& message
,
52 const WebKit::WebString
& source_url
) {
54 virtual void postConsoleMessageToWorkerObject(
58 const WebKit::WebString
& message
,
60 const WebKit::WebString
& source_url
);
61 virtual void confirmMessageFromWorkerObject(bool has_pending_activity
);
62 virtual void reportPendingActivity(bool has_pending_activity
);
63 virtual void workerContextClosed();
64 virtual void workerContextDestroyed();
66 virtual WebKit::WebNotificationPresenter
* notificationPresenter();
68 virtual WebKit::WebApplicationCacheHost
* createApplicationCacheHost(
69 WebKit::WebApplicationCacheHostClient
* client
);
71 virtual bool allowDatabase(WebKit::WebFrame
* frame
,
72 const WebKit::WebString
& name
,
73 const WebKit::WebString
& display_name
,
74 unsigned long estimated_size
);
75 virtual bool allowFileSystem();
76 virtual void openFileSystem(WebKit::WebFileSystem::Type type
,
79 WebKit::WebFileSystemCallbacks
* callbacks
);
80 virtual void dispatchDevToolsMessage(const WebKit::WebString
&);
81 virtual void saveDevToolsAgentState(const WebKit::WebString
&);
83 void EnsureWorkerContextTerminates();
85 void set_devtools_agent(SharedWorkerDevToolsAgent
* devtools_agent
) {
86 devtools_agent_
= devtools_agent
;
90 bool Send(IPC::Message
* message
);
93 int appcache_host_id_
;
94 WebSharedWorkerStub
* stub_
;
95 base::WeakPtrFactory
<WebSharedWorkerClientProxy
> weak_factory_
;
96 SharedWorkerDevToolsAgent
* devtools_agent_
;
98 DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerClientProxy
);
101 #endif // CONTENT_WORKER_WEBWORKERCLIENT_PROXY_H_