summaryrefslogtreecommitdiffstats
path: root/chrome/worker/nativewebworker_impl.h
blob: 29d85c9fcd95be695855a65cfefb67558ab1f123 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_WORKER_NATIVEWORKER_H_
#define CHROME_WORKER_NATIVEWORKER_H_

#include "base/basictypes.h"
#include "webkit/api/public/WebWorker.h"
#include "webkit/api/public/WebWorkerClient.h"


// Forward declaration for the listener thread pointer.
class NativeWebWorkerListenerThread;

// This class is used by the worker process code to talk to the Native Client
// worker implementation.
class NativeWebWorkerImpl : public WebKit::WebWorker {
 public:
  explicit NativeWebWorkerImpl(WebKit::WebWorkerClient* client);
  virtual ~NativeWebWorkerImpl();

  static WebWorker* create(WebKit::WebWorkerClient* client);

  // WebWorker implementation.
  void startWorkerContext(const WebKit::WebURL& script_url,
                          const WebKit::WebString& user_agent,
                          const WebKit::WebString& source_code);
  void terminateWorkerContext();
  void postMessageToWorkerContext(
      const WebKit::WebString& message,
      const WebKit::WebMessagePortChannelArray& channels);
  void workerObjectDestroyed();

 private:
  WebKit::WebWorkerClient* client_;
  struct NaClApp* nap_;
  struct NaClSrpcChannel* channel_;
  NativeWebWorkerListenerThread* upcall_thread_;
  struct NaClDesc* descs_[2];

  DISALLOW_COPY_AND_ASSIGN(NativeWebWorkerImpl);
};

#endif  // CHROME_WORKER_NATIVEWEBWORKER_H_