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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/plugin.h

Issue 9390028: Remove browser support for non-PPAPI nexes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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
OLDNEW
1 // -*- c++ -*- 1 // -*- c++ -*-
2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 // The portable representation of an instance and root scriptable object. 6 // The portable representation of an instance and root scriptable object.
7 // The PPAPI version of the plugin instantiates a subclass of this class. 7 // The PPAPI version of the plugin instantiates a subclass of this class.
8 8
9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ 9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_
10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ 10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_
11 11
12 #include <stdio.h> 12 #include <stdio.h>
13 13
14 #include <map> 14 #include <map>
15 #include <queue> 15 #include <queue>
16 #include <set> 16 #include <set>
17 #include <string> 17 #include <string>
18 #include <vector> 18 // #include <vector>
jvoung - send to chromium... 2012/02/16 01:22:36 one more commented out header
sehr (please use chromium) 2012/02/16 05:22:08 Ugh, three passes plus two greps missed this one..
19 19
20 #include "native_client/src/include/nacl_macros.h" 20 #include "native_client/src/include/nacl_macros.h"
21 #include "native_client/src/include/nacl_scoped_ptr.h" 21 #include "native_client/src/include/nacl_scoped_ptr.h"
22 #include "native_client/src/include/nacl_string.h" 22 #include "native_client/src/include/nacl_string.h"
23 #include "native_client/src/trusted/plugin/file_downloader.h" 23 #include "native_client/src/trusted/plugin/file_downloader.h"
24 #include "native_client/src/trusted/plugin/method_map.h"
25 #include "native_client/src/trusted/plugin/nacl_subprocess.h" 24 #include "native_client/src/trusted/plugin/nacl_subprocess.h"
26 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" 25 #include "native_client/src/trusted/plugin/pnacl_coordinator.h"
27 #include "native_client/src/trusted/plugin/service_runtime.h" 26 #include "native_client/src/trusted/plugin/service_runtime.h"
28 #include "native_client/src/trusted/plugin/utility.h" 27 #include "native_client/src/trusted/plugin/utility.h"
29 28
30 #include "ppapi/cpp/private/var_private.h" 29 #include "ppapi/cpp/private/var_private.h"
31 // for pp::VarPrivate 30 // for pp::VarPrivate
32 #include "ppapi/cpp/private/instance_private.h" 31 #include "ppapi/cpp/private/instance_private.h"
33 #include "ppapi/cpp/rect.h" 32 #include "ppapi/cpp/rect.h"
34 #include "ppapi/cpp/url_loader.h" 33 #include "ppapi/cpp/url_loader.h"
(...skipping 19 matching lines...) Expand all
54 } 53 }
55 54
56 namespace ppapi_proxy { 55 namespace ppapi_proxy {
57 class BrowserPpp; 56 class BrowserPpp;
58 } 57 }
59 58
60 namespace plugin { 59 namespace plugin {
61 60
62 class ErrorInfo; 61 class ErrorInfo;
63 class Manifest; 62 class Manifest;
64 class PnaclCoordinator;
65 class ProgressEvent; 63 class ProgressEvent;
66 class ScriptableHandle; 64 class ScriptablePlugin;
67
68 typedef enum {
69 METHOD_CALL = 0,
70 PROPERTY_GET,
71 PROPERTY_SET
72 } CallType;
73
74 65
75 class Plugin : public pp::InstancePrivate { 66 class Plugin : public pp::InstancePrivate {
76 public: 67 public:
77 // Factory method for creation. 68 // Factory method for creation.
78 static Plugin* New(PP_Instance instance); 69 static Plugin* New(PP_Instance instance);
79 70
80 // ----- Methods inherited from pp::Instance: 71 // ----- Methods inherited from pp::Instance:
81 72
82 // Initializes this plugin with <embed/object ...> tag attribute count |argc|, 73 // Initializes this plugin with <embed/object ...> tag attribute count |argc|,
83 // names |argn| and values |argn|. Returns false on failure. 74 // names |argn| and values |argn|. Returns false on failure.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 }; 154 };
164 // Report successful loading of a module. 155 // Report successful loading of a module.
165 void ReportLoadSuccess(LengthComputable length_computable, 156 void ReportLoadSuccess(LengthComputable length_computable,
166 uint64_t loaded_bytes, 157 uint64_t loaded_bytes,
167 uint64_t total_bytes); 158 uint64_t total_bytes);
168 // Report an error that was encountered while loading a module. 159 // Report an error that was encountered while loading a module.
169 void ReportLoadError(const ErrorInfo& error_info); 160 void ReportLoadError(const ErrorInfo& error_info);
170 // Report loading a module was aborted, typically due to user action. 161 // Report loading a module was aborted, typically due to user action.
171 void ReportLoadAbort(); 162 void ReportLoadAbort();
172 163
164 // Write a text string on the JavaScript console.
165 void AddToConsole(const nacl::string& text);
166
173 // Dispatch a JavaScript event to indicate a key step in loading. 167 // Dispatch a JavaScript event to indicate a key step in loading.
174 // |event_type| is a character string indicating which type of progress 168 // |event_type| is a character string indicating which type of progress
175 // event (loadstart, progress, error, abort, load, loadend). Events are 169 // event (loadstart, progress, error, abort, load, loadend). Events are
176 // enqueued on the JavaScript event loop, which then calls back through 170 // enqueued on the JavaScript event loop, which then calls back through
177 // DispatchProgressEvent. 171 // DispatchProgressEvent.
178 void EnqueueProgressEvent(const char* event_type); 172 void EnqueueProgressEvent(const char* event_type);
179 void EnqueueProgressEvent(const char* event_type, 173 void EnqueueProgressEvent(const char* event_type,
180 const nacl::string& url, 174 const nacl::string& url,
181 LengthComputable length_computable, 175 LengthComputable length_computable,
182 uint64_t loaded_bytes, 176 uint64_t loaded_bytes,
(...skipping 12 matching lines...) Expand all
195 void ReportSelLdrLoadStatus(int status); 189 void ReportSelLdrLoadStatus(int status);
196 190
197 // Report nexe death after load to JS and shut down the proxy. 191 // Report nexe death after load to JS and shut down the proxy.
198 void ReportDeadNexe(); 192 void ReportDeadNexe();
199 193
200 // The embed/object tag argument list. 194 // The embed/object tag argument list.
201 int argc() const { return argc_; } 195 int argc() const { return argc_; }
202 char** argn() const { return argn_; } 196 char** argn() const { return argn_; }
203 char** argv() const { return argv_; } 197 char** argv() const { return argv_; }
204 198
205 BrowserInterface* browser_interface() const { return browser_interface_; }
206 Plugin* plugin() const { return const_cast<Plugin*>(this); } 199 Plugin* plugin() const { return const_cast<Plugin*>(this); }
207 200
208 // URL resolution support. 201 // URL resolution support.
209 // plugin_base_url is the URL used for resolving relative URLs used in 202 // plugin_base_url is the URL used for resolving relative URLs used in
210 // src="...". 203 // src="...".
211 nacl::string plugin_base_url() const { return plugin_base_url_; } 204 nacl::string plugin_base_url() const { return plugin_base_url_; }
212 void set_plugin_base_url(nacl::string url) { plugin_base_url_ = url; } 205 void set_plugin_base_url(nacl::string url) { plugin_base_url_ = url; }
213 // manifest_base_url is the URL used for resolving relative URLs mentioned 206 // manifest_base_url is the URL used for resolving relative URLs mentioned
214 // in manifest files. If the manifest is a data URI, this is an empty string. 207 // in manifest files. If the manifest is a data URI, this is an empty string.
215 nacl::string manifest_base_url() const { return manifest_base_url_; } 208 nacl::string manifest_base_url() const { return manifest_base_url_; }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // NB: this is currently invoked from the main thread. If we ever 248 // NB: this is currently invoked from the main thread. If we ever
256 // move it off the main thread (eliminate the possibility of a 249 // move it off the main thread (eliminate the possibility of a
257 // malicious nexe that isn't linked against / doesn't use our 250 // malicious nexe that isn't linked against / doesn't use our
258 // ppapi_proxy code that blocks the main thread on the RPCs used 251 // ppapi_proxy code that blocks the main thread on the RPCs used
259 // here), then we will need to take care to ensure that the error 252 // here), then we will need to take care to ensure that the error
260 // and crash reporting state machine (see NexeDidCrash comment) 253 // and crash reporting state machine (see NexeDidCrash comment)
261 // continues to work. 254 // continues to work.
262 bool StartProxiedExecution(NaClSrpcChannel* srpc_channel, 255 bool StartProxiedExecution(NaClSrpcChannel* srpc_channel,
263 ErrorInfo* error_info); 256 ErrorInfo* error_info);
264 257
265 // Determines whether experimental APIs are usable. 258 // Support for property getting.
266 static bool ExperimentalJavaScriptApisAreEnabled(); 259 typedef void (Plugin::* PropertyGetter)(NaClSrpcArg* prop_value);
267 260 void AddPropertyGet(const nacl::string& prop_name, PropertyGetter getter);
268 // Methods for method and property dispatch. 261 bool HasProperty(const nacl::string& prop_name);
269 bool InitParams(uintptr_t method_id, CallType call_type, SrpcParams* params); 262 bool GetProperty(const nacl::string& prop_name, NaClSrpcArg* prop_value);
270 bool HasMethod(uintptr_t method_id, CallType call_type); 263 // The supported property getters.
271 bool Invoke(uintptr_t method_id, CallType call_type, SrpcParams* params); 264 void GetExitStatus(NaClSrpcArg* prop_value);
272 std::vector<uintptr_t>* GetPropertyIdentifiers() { 265 void GetLastError(NaClSrpcArg* prop_value);
273 return property_get_methods_.Keys(); 266 void GetReadyStateProperty(NaClSrpcArg* prop_value);
274 }
275 267
276 // The size returned when a file download operation is unable to determine 268 // The size returned when a file download operation is unable to determine
277 // the size of the file to load. W3C ProgressEvents specify that unknown 269 // the size of the file to load. W3C ProgressEvents specify that unknown
278 // sizes return 0. 270 // sizes return 0.
279 static const uint64_t kUnknownBytes = 0; 271 static const uint64_t kUnknownBytes = 0;
280 272
281 // Getter for PPAPI proxy interface. 273 // Getter for PPAPI proxy interface.
282 ppapi_proxy::BrowserPpp* ppapi_proxy() const { return ppapi_proxy_; } 274 ppapi_proxy::BrowserPpp* ppapi_proxy() const { return ppapi_proxy_; }
283 275
284 // Called back by CallOnMainThread. Dispatches the first enqueued progress 276 // Called back by CallOnMainThread. Dispatches the first enqueued progress
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 #ifndef HACK_FOR_MACOS_HANG_REMOVED 322 #ifndef HACK_FOR_MACOS_HANG_REMOVED
331 void XYZZY(const nacl::string& url, pp::VarPrivate js_callback); 323 void XYZZY(const nacl::string& url, pp::VarPrivate js_callback);
332 #endif // HACK_FOR_MACOS_HANG_REMOVED 324 #endif // HACK_FOR_MACOS_HANG_REMOVED
333 // Prevent construction and destruction from outside the class: 325 // Prevent construction and destruction from outside the class:
334 // must use factory New() method instead. 326 // must use factory New() method instead.
335 explicit Plugin(PP_Instance instance); 327 explicit Plugin(PP_Instance instance);
336 // The browser will invoke the destructor via the pp::Instance 328 // The browser will invoke the destructor via the pp::Instance
337 // pointer to this object, not from base's Delete(). 329 // pointer to this object, not from base's Delete().
338 ~Plugin(); 330 ~Plugin();
339 331
340 bool Init(BrowserInterface* browser_interface, 332 bool Init(int argc, char* argn[], char* argv[]);
341 int argc,
342 char* argn[],
343 char* argv[]);
344 void LoadMethods();
345 // Shuts down socket connection, service runtime, and receive thread, 333 // Shuts down socket connection, service runtime, and receive thread,
346 // in this order, for the main nacl subprocess. 334 // in this order, for the main nacl subprocess.
347 void ShutDownSubprocesses(); 335 void ShutDownSubprocesses();
348 336
349 ScriptableHandle* scriptable_handle() const { return scriptable_handle_; } 337 ScriptablePlugin* scriptable_plugin() const { return scriptable_plugin_; }
350 void set_scriptable_handle(ScriptableHandle* scriptable_handle) { 338 void set_scriptable_plugin(ScriptablePlugin* scriptable_plugin) {
351 scriptable_handle_ = scriptable_handle; 339 scriptable_plugin_ = scriptable_plugin;
352 } 340 }
353 341
354 // Access the service runtime for the main NaCl subprocess. 342 // Access the service runtime for the main NaCl subprocess.
355 ServiceRuntime* main_service_runtime() const { 343 ServiceRuntime* main_service_runtime() const {
356 return main_subprocess_.service_runtime(); 344 return main_subprocess_.service_runtime();
357 } 345 }
358 346
359 // Setting the properties and methods exported.
360 void AddPropertyGet(RpcFunction function_ptr,
361 const char* name,
362 const char* outs);
363
364 // Help load a nacl module, from the file specified in wrapper. 347 // Help load a nacl module, from the file specified in wrapper.
365 // This will fully initialize the |subprocess| if the load was successful. 348 // This will fully initialize the |subprocess| if the load was successful.
366 bool LoadNaClModuleCommon(nacl::DescWrapper* wrapper, 349 bool LoadNaClModuleCommon(nacl::DescWrapper* wrapper,
367 NaClSubprocess* subprocess, 350 NaClSubprocess* subprocess,
368 const Manifest* manifest, 351 const Manifest* manifest,
369 bool should_report_uma, 352 bool should_report_uma,
370 ErrorInfo* error_info, 353 ErrorInfo* error_info,
371 pp::CompletionCallback init_done_cb, 354 pp::CompletionCallback init_done_cb,
372 pp::CompletionCallback crash_cb); 355 pp::CompletionCallback crash_cb);
373 bool StartSrpcServices(NaClSubprocess* subprocess, ErrorInfo* error_info);
374 bool StartSrpcServicesCommon(NaClSubprocess* subprocess,
375 ErrorInfo* error_info);
376 bool StartJSObjectProxy(NaClSubprocess* subprocess, ErrorInfo* error_info);
377
378 MethodInfo* GetMethodInfo(uintptr_t method_id, CallType call_type);
379 356
380 // Callback used when getting the URL for the .nexe file. If the URL loading 357 // Callback used when getting the URL for the .nexe file. If the URL loading
381 // is successful, the file descriptor is opened and can be passed to sel_ldr 358 // is successful, the file descriptor is opened and can be passed to sel_ldr
382 // with the sandbox on. 359 // with the sandbox on.
383 void NexeFileDidOpen(int32_t pp_error); 360 void NexeFileDidOpen(int32_t pp_error);
384 void NexeFileDidOpenContinuation(int32_t pp_error); 361 void NexeFileDidOpenContinuation(int32_t pp_error);
385 362
386 // Callback used when the reverse channel closes. This is an 363 // Callback used when the reverse channel closes. This is an
387 // asynchronous event that might turn into a JavaScript error or 364 // asynchronous event that might turn into a JavaScript error or
388 // crash event -- this is controlled by the two state variables 365 // crash event -- this is controlled by the two state variables
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 bool NexeIsContentHandler() const; 424 bool NexeIsContentHandler() const;
448 425
449 // Callback used when loading a URL for SRPC-based StreamAsFile(). 426 // Callback used when loading a URL for SRPC-based StreamAsFile().
450 void UrlDidOpenForStreamAsFile(int32_t pp_error, 427 void UrlDidOpenForStreamAsFile(int32_t pp_error,
451 FileDownloader*& url_downloader, 428 FileDownloader*& url_downloader,
452 PP_CompletionCallback pp_callback); 429 PP_CompletionCallback pp_callback);
453 430
454 // Shuts down the proxy for PPAPI nexes. 431 // Shuts down the proxy for PPAPI nexes.
455 void ShutdownProxy(); // Nexe shutdown + proxy deletion. 432 void ShutdownProxy(); // Nexe shutdown + proxy deletion.
456 433
457 BrowserInterface* browser_interface_; 434 ScriptablePlugin* scriptable_plugin_;
458 ScriptableHandle* scriptable_handle_;
459 435
460 int argc_; 436 int argc_;
461 char** argn_; 437 char** argn_;
462 char** argv_; 438 char** argv_;
463 439
464 // Keep track of the NaCl module subprocess that was spun up in the plugin. 440 // Keep track of the NaCl module subprocess that was spun up in the plugin.
465 NaClSubprocess main_subprocess_; 441 NaClSubprocess main_subprocess_;
466 442
467 nacl::string plugin_base_url_; 443 nacl::string plugin_base_url_;
468 nacl::string manifest_base_url_; 444 nacl::string manifest_base_url_;
469 nacl::string manifest_url_; 445 nacl::string manifest_url_;
470 ReadyState nacl_ready_state_; 446 ReadyState nacl_ready_state_;
471 bool nexe_error_reported_; // error or crash reported 447 bool nexe_error_reported_; // error or crash reported
472 448
473 nacl::DescWrapperFactory* wrapper_factory_; 449 nacl::DescWrapperFactory* wrapper_factory_;
474 450
475 MethodMap property_get_methods_; 451 std::map<nacl::string, PropertyGetter> property_getters_;
476 452
477 // File download support. |nexe_downloader_| can be opened with a specific 453 // File download support. |nexe_downloader_| can be opened with a specific
478 // callback to run when the file has been downloaded and is opened for 454 // callback to run when the file has been downloaded and is opened for
479 // reading. We use one downloader for all URL downloads to prevent issuing 455 // reading. We use one downloader for all URL downloads to prevent issuing
480 // multiple GETs that might arrive out of order. For example, this will 456 // multiple GETs that might arrive out of order. For example, this will
481 // prevent a GET of a NaCl manifest while a .nexe GET is pending. Note that 457 // prevent a GET of a NaCl manifest while a .nexe GET is pending. Note that
482 // this will also prevent simultaneous handling of multiple .nexes on a page. 458 // this will also prevent simultaneous handling of multiple .nexes on a page.
483 FileDownloader nexe_downloader_; 459 FileDownloader nexe_downloader_;
484 pp::CompletionCallbackFactory<Plugin> callback_factory_; 460 pp::CompletionCallbackFactory<Plugin> callback_factory_;
485 461
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // in UpdateDownloadProgress to map a url loader back to the URL being 529 // in UpdateDownloadProgress to map a url loader back to the URL being
554 // downloaded. 530 // downloaded.
555 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; 531 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const;
556 532
557 int64_t time_of_last_progress_event_; 533 int64_t time_of_last_progress_event_;
558 }; 534 };
559 535
560 } // namespace plugin 536 } // namespace plugin
561 537
562 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ 538 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/nacl_subprocess.cc ('k') | ppapi/native_client/src/trusted/plugin/plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698