summaryrefslogtreecommitdiffstats
path: root/chrome/worker/nativewebworker_stub.h
blob: 8075e5446820c6a8345e40ff84d074ceec69c96f (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// 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_NATIVEWEBWORKER_STUB_H_
#define CHROME_WORKER_NATIVEWEBWORKER_STUB_H_
#pragma once
// Native WebWorker support stub header.

#include <stddef.h>

// As we are not including the native client header files, several types
// from them need to be named outside of structure/method declarations to
// avoid compiler warnings/errors.

struct NaClApp;
struct NaClDesc;
struct NaClSrpcChannel;

namespace WebKit {
class WebWorkerClient;
}

extern "C" {
// The thunk type used by upcall (postMessage from worker) handling.
typedef void (*NativeWorkerPostMessageFunc)(const char *str,
                                            WebKit::WebWorkerClient* client);

// Start a native webworker from the module in buffer.
int NaClStartNativeWebWorker(char *buffer,
                             size_t buf_len,
                             struct NaClApp **nap,
                             struct NaClSrpcChannel **untrusted_channel);

// Performs a postMessage to the worker.
int NaClPostMessageToNativeWebWorker(char *buffer,
                                     size_t buf_len,
                                     struct NaClApp **nap,
                                     struct NaClSrpcChannel **untrusted_ch);

// Causes a native web worker to be shut down.
int NaClTerminateNativeWebWorker(struct NaClApp **nap,
                                 struct NaClSrpcChannel **untrusted_channel);

// Creates a channel that can be used to receive upcalls (postMessage from
// a worker).
int NaClCreateUpcallChannel(struct NaClDesc* desc[2]);

// Part of the initialization of a worker.  Sends the descriptor to the
// worker library to indicate where to send postMessage RPCs.
int NaClSrpcSendUpcallDesc(struct NaClSrpcChannel *channel,
                           struct NaClDesc *nacl_desc);

// Runs an SRPC server loop on the specified channel.  The post_message_func
// is invoked whenever the "postMessage" RPC is received.
int NaClSrpcListenerLoop(struct NaClDesc *chrome_desc,
                         NativeWorkerPostMessageFunc func,
                         WebKit::WebWorkerClient* client);

// Destroys the upcall channel.
void NaClDestroyUpcallChannel(struct NaClDesc* desc[2]);
}

#endif  // CHROME_WORKER_NATIVEWEBWORKER_STUB_H_