Home | History | Annotate | Download | only in worker
      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.
      4 
      5 #ifndef CONTENT_WORKER_WEBWORKERCLIENT_PROXY_H_
      6 #define CONTENT_WORKER_WEBWORKERCLIENT_PROXY_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/memory/weak_ptr.h"
     10 #include "ipc/ipc_channel.h"
     11 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h"
     12 
     13 namespace blink {
     14 class WebApplicationCacheHost;
     15 class WebApplicationCacheHostClient;
     16 class WebFrame;
     17 class WebSecurityOrigin;
     18 }
     19 
     20 namespace content {
     21 
     22 class SharedWorkerDevToolsAgent;
     23 class WebSharedWorkerStub;
     24 class WorkerWebApplicationCacheHostImpl;
     25 
     26 // This class receives IPCs from the renderer and calls the WebCore::Worker
     27 // implementation (after the data types have been converted by glue code).  It
     28 // is also called by the worker code and converts these function calls into
     29 // IPCs that are sent to the renderer, where they're converted back to function
     30 // calls by WebWorkerProxy.
     31 class WebSharedWorkerClientProxy : public blink::WebSharedWorkerClient {
     32  public:
     33   WebSharedWorkerClientProxy(int route_id, WebSharedWorkerStub* stub);
     34   virtual ~WebSharedWorkerClientProxy();
     35 
     36   // WebSharedWorkerClient implementation.
     37   virtual void workerContextClosed();
     38   virtual void workerContextDestroyed();
     39   virtual void workerScriptLoaded();
     40   virtual void workerScriptLoadFailed();
     41   virtual void selectAppCacheID(long long app_cache_id);
     42 
     43   virtual blink::WebNotificationPresenter* notificationPresenter();
     44 
     45   virtual blink::WebApplicationCacheHost* createApplicationCacheHost(
     46       blink::WebApplicationCacheHostClient* client);
     47   virtual blink::WebWorkerPermissionClientProxy*
     48       createWorkerPermissionClientProxy(
     49           const blink::WebSecurityOrigin& origin);
     50 
     51   virtual void dispatchDevToolsMessage(const blink::WebString&);
     52   virtual void saveDevToolsAgentState(const blink::WebString&);
     53 
     54   void EnsureWorkerContextTerminates();
     55 
     56   void set_devtools_agent(SharedWorkerDevToolsAgent* devtools_agent) {
     57     devtools_agent_ = devtools_agent;
     58   }
     59 
     60  private:
     61   bool Send(IPC::Message* message);
     62 
     63   int route_id_;
     64   int appcache_host_id_;
     65   WebSharedWorkerStub* stub_;
     66   base::WeakPtrFactory<WebSharedWorkerClientProxy> weak_factory_;
     67   SharedWorkerDevToolsAgent* devtools_agent_;
     68   WorkerWebApplicationCacheHostImpl* app_cache_host_;
     69 
     70   DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerClientProxy);
     71 };
     72 
     73 }  // namespace content
     74 
     75 #endif  // CONTENT_WORKER_WEBWORKERCLIENT_PROXY_H_
     76