OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2008 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can | |
4 * be found in the LICENSE file. | |
5 */ | |
6 | |
7 // Portable representation of scriptable NaClDesc. | |
8 | |
9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_DESC_BASED_HANDLE_H_ | |
10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_DESC_BASED_HANDLE_H_ | |
11 | |
12 #include <stdio.h> | |
13 #include <map> | |
14 | |
15 #include "native_client/src/include/nacl_macros.h" | |
16 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | |
17 #include "native_client/src/trusted/plugin/srpc/portable_handle.h" | |
18 #include "native_client/src/trusted/plugin/srpc/utility.h" | |
19 | |
20 struct NaClDesc; | |
21 | |
22 namespace nacl { | |
23 class DescWrapper; | |
24 } // namespace nacl | |
25 | |
26 namespace plugin { | |
27 | |
28 class Plugin; | |
29 | |
30 // DescBasedHandles are used to make NaClDesc objects scriptable by JavaScript. | |
31 class DescBasedHandle : public PortableHandle { | |
32 public: | |
33 static DescBasedHandle* New(Plugin* plugin, nacl::DescWrapper* wrapper); | |
34 | |
35 void Invalidate() { } | |
36 | |
37 virtual BrowserInterface* browser_interface() const; | |
38 virtual Plugin* plugin() const { return plugin_; } | |
39 // Get the contained descriptor. | |
40 virtual nacl::DescWrapper* wrapper() const { return wrapper_; } | |
41 virtual NaClDesc* desc() const { | |
42 if (NULL == wrapper_) { | |
43 return NULL; | |
44 } | |
45 return wrapper_->desc(); | |
46 } | |
47 | |
48 protected: | |
49 DescBasedHandle(); | |
50 virtual ~DescBasedHandle(); | |
51 bool Init(Plugin* plugin, nacl::DescWrapper* wrapper); | |
52 | |
53 private: | |
54 NACL_DISALLOW_COPY_AND_ASSIGN(DescBasedHandle); | |
55 void LoadMethods(); | |
56 Plugin* plugin_; | |
57 nacl::DescWrapper* wrapper_; | |
58 }; | |
59 | |
60 } // namespace plugin | |
61 | |
62 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_DESC_BASED_HANDLE_H_ | |
OLD | NEW |