Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: src/trusted/plugin/srpc/plugin.h

Issue 2981011: Move plugin/srpc contents to the more appropriately named plugin/common.... (Closed) Base URL: http://nativeclient.googlecode.com/svn/trunk/src/native_client/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/trusted/plugin/srpc/nexe_arch.cc ('k') | src/trusted/plugin/srpc/plugin.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // The portable representation of an instance and root scriptable object.
8 // The ActiveX, NPAPI, and Pepper versions of the plugin instantiate
9 // subclasses of this class.
10
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_PLUGIN_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_PLUGIN_H_
13
14 #include <stdio.h>
15
16 #include "native_client/src/include/nacl_macros.h"
17 #include "native_client/src/include/nacl_string.h"
18 #include "native_client/src/trusted/plugin/api_defines.h"
19 #include "native_client/src/trusted/plugin/srpc/service_runtime.h"
20 #include "native_client/src/trusted/plugin/srpc/portable_handle.h"
21 #include "native_client/src/trusted/plugin/srpc/utility.h"
22
23 namespace nacl {
24 class DescWrapperFactory;
25 } // namespace nacl
26
27 namespace plugin {
28
29 class StreamShmBuffer;
30 class ScriptableHandle;
31
32 class Plugin : public PortableHandle {
33 public:
34 void Invalidate();
35
36 // Load from the local URL saved in local_url.
37 // Updates local_url(), nacl_module_origin() and logical_url().
38 bool Load(nacl::string logical_url, const char* local_url);
39 // Load nexe binary from the provided buffer.
40 // Updates local_url(), nacl_module_origin() and logical_url().
41 bool Load(nacl::string logical_url,
42 const char* local_url,
43 plugin::StreamShmBuffer* buffer);
44
45 // Log a message by sending it to the service runtime.
46 bool LogAtServiceRuntime(int severity, nacl::string msg);
47
48 // Returns the argument value for the specified key, or NULL if not found.
49 // The callee retains ownership of the result.
50 char* LookupArgument(const char* key);
51
52 // To indicate successful loading of a module, invoke the onload handler.
53 bool RunOnloadHandler();
54 // To indicate unsuccessful loading of a module, invoke the onfail handler.
55 bool RunOnfailHandler();
56
57 // overriding virtual methods
58 virtual bool InvokeEx(uintptr_t method_id,
59 CallType call_type,
60 SrpcParams* params);
61 virtual bool HasMethodEx(uintptr_t method_id, CallType call_type);
62 virtual bool InitParamsEx(uintptr_t method_id,
63 CallType call_type,
64 SrpcParams* params);
65
66 // The unique identifier for this plugin instance.
67 InstanceIdentifier instance_id() { return instance_id_; }
68
69 // The embed/object tag argument list.
70 int argc() const { return argc_; }
71 char** argn() const { return argn_; }
72 char** argv() const { return argv_; }
73
74 virtual BrowserInterface* browser_interface() const {
75 return browser_interface_;
76 }
77 virtual Plugin* plugin() const { return const_cast<Plugin*>(this); }
78 ScriptableHandle* scriptable_handle() const { return scriptable_handle_; }
79 void set_scriptable_handle(ScriptableHandle* scriptable_handle) {
80 scriptable_handle_ = scriptable_handle;
81 }
82
83 // Returns the URL of the locally-cached copy of the downloaded NaCl
84 // module, if any. May be NULL, e.g. in Chrome.
85 const char* local_url() const { return local_url_; }
86 void set_local_url(const char* url);
87
88 // Returns the logical URL of NaCl module as defined by the "src" or
89 // "nexes" attribute (and thus seen by the user).
90 // TODO(sehr): this is derived from what the NPStream object reports, and
91 // we need to investigate how streams report redirection (or if they do)
92 // for our origin checks, etc.
93 const char* logical_url() const { return logical_url_; }
94 void set_logical_url(const char* url);
95
96 // Origin of page with the embed tag that created this plugin instance.
97 nacl::string origin() const { return origin_; }
98
99 // Origin of NaCl module.
100 nacl::string nacl_module_origin() const { return nacl_module_origin_; }
101 void set_nacl_module_origin(nacl::string origin) {
102 nacl_module_origin_ = origin;
103 }
104
105 // Each nexe has a canonical socket address that it will respond to
106 // Connect requests on.
107 ScriptableHandle* socket_address() const { return socket_address_; }
108 // TODO(sehr): document this.
109 ScriptableHandle* socket() const { return socket_; }
110
111 // The Firefox plugin multimedia interface.
112 // Enable video there.
113 virtual void EnableVideo() { }
114 // Create a listener thread and initialize the nacl module.
115 virtual bool InitializeModuleMultimedia(ScriptableHandle* raw_channel,
116 ServiceRuntime* service_runtime) {
117 UNREFERENCED_PARAMETER(raw_channel);
118 UNREFERENCED_PARAMETER(service_runtime);
119 return true;
120 }
121 // Shut down the multimedia system, destroying the listener thread.
122 virtual void ShutdownMultimedia() { }
123
124 // Width is the width in pixels of the region this instance occupies.
125 int32_t width() const { return width_; }
126 void set_width(int32_t width) { width_ = width; }
127
128 // Height is the height in pixels of the region this instance occupies.
129 int32_t height() const { return height_; }
130 void set_height(int32_t height) { height_ = height; }
131
132 // Video_update_mode tells how the multimedia API should update its window.
133 int32_t video_update_mode() const { return video_update_mode_; }
134 void set_video_update_mode(int32_t video_update_mode) {
135 video_update_mode_ = video_update_mode;
136 }
137
138 nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; }
139
140 // Complex methods to set member data.
141 bool SetNexesPropertyImpl(const char* nexes_attrs);
142 bool SetSrcPropertyImpl(const nacl::string &url);
143
144 // Requesting a nacl module from a specified url.
145 virtual bool RequestNaClModule(const nacl::string& url) = 0;
146
147 // Start up proxied execution of the browser API.
148 virtual void StartProxiedExecution(NaClSrpcChannel* srpc_channel) = 0;
149
150 protected:
151 Plugin();
152 virtual ~Plugin();
153 bool Init(BrowserInterface* browser_interface,
154 InstanceIdentifier instance_id,
155 int argc,
156 char* argn[],
157 char* argv[]);
158 void LoadMethods();
159 ServiceRuntime* service_runtime_;
160
161 bool receive_thread_running_;
162 struct NaClThread receive_thread_;
163
164 private:
165 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin);
166 InstanceIdentifier instance_id_;
167 BrowserInterface* browser_interface_;
168 ScriptableHandle* scriptable_handle_;
169
170 int argc_;
171 char** argn_;
172 char** argv_;
173
174 ScriptableHandle* socket_address_;
175 ScriptableHandle* socket_;
176 char* local_url_; // (from malloc)
177 char* logical_url_; // (from malloc)
178
179 nacl::string origin_;
180 nacl::string nacl_module_origin_;
181
182 bool origin_valid_;
183 int32_t height_;
184 int32_t width_;
185 int32_t video_update_mode_;
186
187 nacl::DescWrapperFactory* wrapper_factory_;
188
189 void ShutDownReceiveThread();
190
191 static bool SendAsyncMessage(void* obj, SrpcParams* params,
192 nacl::DescWrapper** fds, int fds_count);
193 static bool SendAsyncMessage0(void* obj, SrpcParams* params);
194 static bool SendAsyncMessage1(void* obj, SrpcParams* params);
195 };
196
197 // MutexLock support for video locking. It is in this file to avoid copying
198 // between the NPAPI and PPAPI hookups.
199 extern void VideoGlobalLock();
200 extern void VideoGlobalUnlock();
201
202 class VideoScopedGlobalLock {
203 public:
204 VideoScopedGlobalLock() { VideoGlobalLock(); }
205 ~VideoScopedGlobalLock() { VideoGlobalUnlock(); }
206
207 private:
208 NACL_DISALLOW_COPY_AND_ASSIGN(VideoScopedGlobalLock);
209 };
210
211 } // namespace plugin
212
213 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_PLUGIN_H_
OLDNEW
« no previous file with comments | « src/trusted/plugin/srpc/nexe_arch.cc ('k') | src/trusted/plugin/srpc/plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698