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

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

Issue 11783112: Remove the NaCl SRPC proxy from Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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_
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Factory method for creation. 67 // Factory method for creation.
68 static Plugin* New(PP_Instance instance); 68 static Plugin* New(PP_Instance instance);
69 69
70 // ----- Methods inherited from pp::Instance: 70 // ----- Methods inherited from pp::Instance:
71 71
72 // Initializes this plugin with <embed/object ...> tag attribute count |argc|, 72 // Initializes this plugin with <embed/object ...> tag attribute count |argc|,
73 // names |argn| and values |argn|. Returns false on failure. 73 // names |argn| and values |argn|. Returns false on failure.
74 // Gets called by the browser right after New(). 74 // Gets called by the browser right after New().
75 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); 75 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
76 76
77 // Handles view changes from the browser. 77 // Handles document load, when the plugin is a MIME type handler.
78 virtual void DidChangeView(const pp::View& view);
79
80 // Handles gaining or losing focus.
81 virtual void DidChangeFocus(bool has_focus);
82
83 // Handles input events delivered from the browser to this plugin element.
84 virtual bool HandleInputEvent(const pp::InputEvent& event);
85
86 // Handles gaining or losing focus.
87 virtual bool HandleDocumentLoad(const pp::URLLoader& url_loader); 78 virtual bool HandleDocumentLoad(const pp::URLLoader& url_loader);
88 79
89 // Returns a scriptable reference to this plugin element. 80 // Returns a scriptable reference to this plugin element.
90 // Called by JavaScript document.getElementById(plugin_id). 81 // Called by JavaScript document.getElementById(plugin_id).
91 virtual pp::Var GetInstanceObject(); 82 virtual pp::Var GetInstanceObject();
92 83
93 // Handles postMessage from browser
94 virtual void HandleMessage(const pp::Var& message);
95
96 // ----- Plugin interface support. 84 // ----- Plugin interface support.
97 85
98 // Load support. 86 // Load support.
99 // NaCl module can be loaded given a DescWrapper. 87 // NaCl module can be loaded given a DescWrapper.
100 // 88 //
101 // Starts NaCl module but does not wait until low-level 89 // Starts NaCl module but does not wait until low-level
102 // initialization (e.g., ld.so dynamic loading of manifest files) is 90 // initialization (e.g., ld.so dynamic loading of manifest files) is
103 // done. The module will become ready later, asynchronously. Other 91 // done. The module will become ready later, asynchronously. Other
104 // event handlers should block until the module is ready before 92 // event handlers should block until the module is ready before
105 // trying to communicate with it, i.e., until nacl_ready_state is 93 // trying to communicate with it, i.e., until nacl_ready_state is
106 // DONE. Note, however, we already have another mechanism that 94 // DONE.
107 // prevents event delivery: StartJSObjectProxy plumbs through
108 // NaClSubprocess to SrpcClient which upcalls
109 // Plugin::StartProxiedExecution, which sets ppapi_proxy_. And NULL
110 // == ppapi_proxy_ prevents events from being delivered, even if
111 // nacl_ready_state is DONE.
112 // 95 //
113 // NB: currently we do not time out, so if the untrusted code 96 // NB: currently we do not time out, so if the untrusted code
114 // does not signal that it is ready, then we will deadlock the main 97 // does not signal that it is ready, then we will deadlock the main
115 // thread of the renderer on this subsequent event delivery. We 98 // thread of the renderer on this subsequent event delivery. We
116 // should include a time-out at which point we declare the 99 // should include a time-out at which point we declare the
117 // nacl_ready_state to be done, and let the normal crash detection 100 // nacl_ready_state to be done, and let the normal crash detection
118 // mechanism(s) take over. 101 // mechanism(s) take over.
119 // 102 //
120 // Updates nacl_module_origin() and nacl_module_url(). 103 // Updates nacl_module_origin() and nacl_module_url().
121 bool LoadNaClModule(nacl::DescWrapper* wrapper, ErrorInfo* error_info, 104 bool LoadNaClModule(nacl::DescWrapper* wrapper, ErrorInfo* error_info,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 bool nexe_error_reported() const { return nexe_error_reported_; } 220 bool nexe_error_reported() const { return nexe_error_reported_; }
238 void set_nexe_error_reported(bool val) { 221 void set_nexe_error_reported(bool val) {
239 nexe_error_reported_ = val; 222 nexe_error_reported_ = val;
240 } 223 }
241 224
242 nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; } 225 nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; }
243 226
244 // Requests a NaCl manifest download from a |url| relative to the page origin. 227 // Requests a NaCl manifest download from a |url| relative to the page origin.
245 void RequestNaClManifest(const nacl::string& url); 228 void RequestNaClManifest(const nacl::string& url);
246 229
247 // Start up proxied execution of the browser API.
248 //
249 // NB: this is currently invoked from the main thread. If we ever
250 // move it off the main thread (eliminate the possibility of a
251 // malicious nexe that isn't linked against / doesn't use our
252 // ppapi_proxy code that blocks the main thread on the RPCs used
253 // here), then we will need to take care to ensure that the error
254 // and crash reporting state machine (see NexeDidCrash comment)
255 // continues to work.
256 bool StartProxiedExecution(NaClSrpcChannel* srpc_channel,
257 ErrorInfo* error_info);
258
259 // Support for property getting. 230 // Support for property getting.
260 typedef void (Plugin::* PropertyGetter)(NaClSrpcArg* prop_value); 231 typedef void (Plugin::* PropertyGetter)(NaClSrpcArg* prop_value);
261 void AddPropertyGet(const nacl::string& prop_name, PropertyGetter getter); 232 void AddPropertyGet(const nacl::string& prop_name, PropertyGetter getter);
262 bool HasProperty(const nacl::string& prop_name); 233 bool HasProperty(const nacl::string& prop_name);
263 bool GetProperty(const nacl::string& prop_name, NaClSrpcArg* prop_value); 234 bool GetProperty(const nacl::string& prop_name, NaClSrpcArg* prop_value);
264 // The supported property getters. 235 // The supported property getters.
265 void GetExitStatus(NaClSrpcArg* prop_value); 236 void GetExitStatus(NaClSrpcArg* prop_value);
266 void GetLastError(NaClSrpcArg* prop_value); 237 void GetLastError(NaClSrpcArg* prop_value);
267 void GetReadyStateProperty(NaClSrpcArg* prop_value); 238 void GetReadyStateProperty(NaClSrpcArg* prop_value);
268 239
269 // The size returned when a file download operation is unable to determine 240 // The size returned when a file download operation is unable to determine
270 // the size of the file to load. W3C ProgressEvents specify that unknown 241 // the size of the file to load. W3C ProgressEvents specify that unknown
271 // sizes return 0. 242 // sizes return 0.
272 static const uint64_t kUnknownBytes = 0; 243 static const uint64_t kUnknownBytes = 0;
273 244
274 // Getter for PPAPI proxy interface.
275 ppapi_proxy::BrowserPpp* ppapi_proxy() const { return ppapi_proxy_; }
276
277 // Called back by CallOnMainThread. Dispatches the first enqueued progress 245 // Called back by CallOnMainThread. Dispatches the first enqueued progress
278 // event. 246 // event.
279 void DispatchProgressEvent(int32_t result); 247 void DispatchProgressEvent(int32_t result);
280 248
281 // Requests a URL asynchronously resulting in a call to pp_callback with 249 // Requests a URL asynchronously resulting in a call to pp_callback with
282 // a PP_Error indicating status. On success an open file descriptor 250 // a PP_Error indicating status. On success an open file descriptor
283 // corresponding to the url body is recorded for further lookup. 251 // corresponding to the url body is recorded for further lookup.
284 bool StreamAsFile(const nacl::string& url, 252 bool StreamAsFile(const nacl::string& url,
285 PP_CompletionCallback pp_callback); 253 PP_CompletionCallback pp_callback);
286 // Returns an open POSIX file descriptor retrieved by StreamAsFile() 254 // Returns an open POSIX file descriptor retrieved by StreamAsFile()
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 381
414 // This NEXE is being used as a content type handler rather than directly by 382 // This NEXE is being used as a content type handler rather than directly by
415 // an HTML document. 383 // an HTML document.
416 bool NexeIsContentHandler() const; 384 bool NexeIsContentHandler() const;
417 385
418 // Callback used when loading a URL for SRPC-based StreamAsFile(). 386 // Callback used when loading a URL for SRPC-based StreamAsFile().
419 void UrlDidOpenForStreamAsFile(int32_t pp_error, 387 void UrlDidOpenForStreamAsFile(int32_t pp_error,
420 FileDownloader*& url_downloader, 388 FileDownloader*& url_downloader,
421 PP_CompletionCallback pp_callback); 389 PP_CompletionCallback pp_callback);
422 390
423 // Shuts down the proxy for PPAPI nexes.
424 void ShutdownProxy(); // Nexe shutdown + proxy deletion.
425
426 // Copy the main service runtime's most recent NaClLog output to the 391 // Copy the main service runtime's most recent NaClLog output to the
427 // JavaScript console. Valid to use only after a crash, e.g., via a 392 // JavaScript console. Valid to use only after a crash, e.g., via a
428 // detail level LOG_FATAL NaClLog entry. If the crash was not due 393 // detail level LOG_FATAL NaClLog entry. If the crash was not due
429 // to a LOG_FATAL this method will do nothing. 394 // to a LOG_FATAL this method will do nothing.
430 void CopyCrashLogToJsConsole(); 395 void CopyCrashLogToJsConsole();
431 396
432 ScriptablePlugin* scriptable_plugin_; 397 ScriptablePlugin* scriptable_plugin_;
433 398
434 int argc_; 399 int argc_;
435 char** argn_; 400 char** argn_;
(...skipping 25 matching lines...) Expand all
461 426
462 // The manifest dictionary. Used for looking up resources to be loaded. 427 // The manifest dictionary. Used for looking up resources to be loaded.
463 nacl::scoped_ptr<Manifest> manifest_; 428 nacl::scoped_ptr<Manifest> manifest_;
464 // URL processing interface for use in looking up resources in manifests. 429 // URL processing interface for use in looking up resources in manifests.
465 const pp::URLUtil_Dev* url_util_; 430 const pp::URLUtil_Dev* url_util_;
466 431
467 // A string containing the text description of the last error 432 // A string containing the text description of the last error
468 // produced by this plugin. 433 // produced by this plugin.
469 nacl::string last_error_string_; 434 nacl::string last_error_string_;
470 435
471 // A pointer to the browser end of a proxy pattern connecting the
472 // NaCl plugin to the PPAPI .nexe's PPP interface
473 // (InitializeModule, Shutdown, and GetInterface).
474 // TODO(sehr): this should be a scoped_ptr for shutdown.
475 ppapi_proxy::BrowserPpp* ppapi_proxy_;
476
477 // PPAPI Dev interfaces are disabled by default. 436 // PPAPI Dev interfaces are disabled by default.
478 bool enable_dev_interfaces_; 437 bool enable_dev_interfaces_;
479 438
480 // If we get a DidChangeView event before the nexe is loaded, we store it and 439 // If we get a DidChangeView event before the nexe is loaded, we store it and
481 // replay it to nexe after it's loaded. We need to replay when this View 440 // replay it to nexe after it's loaded. We need to replay when this View
482 // resource is non-is_null(). 441 // resource is non-is_null().
483 pp::View view_to_replay_; 442 pp::View view_to_replay_;
484 443
485 // If we get a HandleDocumentLoad event before the nexe is loaded, we store 444 // If we get a HandleDocumentLoad event before the nexe is loaded, we store
486 // it and replay it to nexe after it's loaded. We need to replay when this 445 // it and replay it to nexe after it's loaded. We need to replay when this
487 // URLLoader resource is non-is_null(). 446 // URLLoader resource is non-is_null().
488 pp::URLLoader document_load_to_replay_; 447 pp::URLLoader document_load_to_replay_;
489 448
490 nacl::string mime_type_; 449 nacl::string mime_type_;
491 450
492 // Keep track of the FileDownloaders created to fetch urls. 451 // Keep track of the FileDownloaders created to fetch urls.
493 std::set<FileDownloader*> url_downloaders_; 452 std::set<FileDownloader*> url_downloaders_;
494 // Keep track of file descriptors opened by StreamAsFile(). 453 // Keep track of file descriptors opened by StreamAsFile().
495 // These are owned by the browser. 454 // These are owned by the browser.
496 std::map<nacl::string, int32_t> url_fd_map_; 455 std::map<nacl::string, int32_t> url_fd_map_;
497 456
498 // Pending progress events. 457 // Pending progress events.
499 std::queue<ProgressEvent*> progress_events_; 458 std::queue<ProgressEvent*> progress_events_;
500 459
501 // Adapter class constructors require a reference to 'this', so we can't
502 // contain them directly.
503 nacl::scoped_ptr<pp::Find_Dev> find_adapter_;
504 nacl::scoped_ptr<pp::MouseLock> mouse_lock_adapter_;
505 nacl::scoped_ptr<pp::Printing_Dev> printing_adapter_;
506 nacl::scoped_ptr<pp::Selection_Dev> selection_adapter_;
507 nacl::scoped_ptr<pp::Zoom_Dev> zoom_adapter_;
508
509 // Used for NexeFileDidOpenContinuation 460 // Used for NexeFileDidOpenContinuation
510 int64_t load_start_; 461 int64_t load_start_;
511 462
512 int64_t init_time_; 463 int64_t init_time_;
513 int64_t ready_time_; 464 int64_t ready_time_;
514 size_t nexe_size_; 465 size_t nexe_size_;
515 466
516 // Callback to receive .nexe and .dso download progress notifications. 467 // Callback to receive .nexe and .dso download progress notifications.
517 static void UpdateDownloadProgress( 468 static void UpdateDownloadProgress(
518 PP_Instance pp_instance, 469 PP_Instance pp_instance,
519 PP_Resource pp_resource, 470 PP_Resource pp_resource,
520 int64_t bytes_sent, 471 int64_t bytes_sent,
521 int64_t total_bytes_to_be_sent, 472 int64_t total_bytes_to_be_sent,
522 int64_t bytes_received, 473 int64_t bytes_received,
523 int64_t total_bytes_to_be_received); 474 int64_t total_bytes_to_be_received);
524 475
525 // Finds the file downloader which owns the given URL loader. This is used 476 // Finds the file downloader which owns the given URL loader. This is used
526 // in UpdateDownloadProgress to map a url loader back to the URL being 477 // in UpdateDownloadProgress to map a url loader back to the URL being
527 // downloaded. 478 // downloaded.
528 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; 479 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const;
529 480
530 int64_t time_of_last_progress_event_; 481 int64_t time_of_last_progress_event_;
531 482
532 const PPB_NaCl_Private* nacl_interface_; 483 const PPB_NaCl_Private* nacl_interface_;
533 }; 484 };
534 485
535 } // namespace plugin 486 } // namespace plugin
536 487
537 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ 488 #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