| OLD | NEW |
| 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 | 18 |
| 19 #include "native_client/src/include/nacl_macros.h" | 19 #include "native_client/src/include/nacl_macros.h" |
| 20 #include "native_client/src/include/nacl_scoped_ptr.h" | 20 #include "native_client/src/include/nacl_scoped_ptr.h" |
| 21 #include "native_client/src/include/nacl_string.h" | 21 #include "native_client/src/include/nacl_string.h" |
| 22 #include "native_client/src/trusted/validator/nacl_file_info.h" | 22 #include "native_client/src/trusted/validator/nacl_file_info.h" |
| 23 | 23 |
| 24 #include "ppapi/c/private/ppb_nacl_private.h" | 24 #include "ppapi/c/private/ppb_nacl_private.h" |
| 25 #include "ppapi/cpp/private/instance_private.h" | 25 #include "ppapi/cpp/private/instance_private.h" |
| 26 #include "ppapi/cpp/private/uma_private.h" |
| 26 #include "ppapi/cpp/url_loader.h" | 27 #include "ppapi/cpp/url_loader.h" |
| 27 #include "ppapi/cpp/var.h" | 28 #include "ppapi/cpp/var.h" |
| 28 #include "ppapi/cpp/view.h" | 29 #include "ppapi/cpp/view.h" |
| 29 | 30 |
| 30 #include "ppapi/native_client/src/trusted/plugin/file_downloader.h" | 31 #include "ppapi/native_client/src/trusted/plugin/file_downloader.h" |
| 31 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" | 32 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" |
| 32 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" | 33 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" |
| 33 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" | 34 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" |
| 34 #include "ppapi/native_client/src/trusted/plugin/utility.h" | 35 #include "ppapi/native_client/src/trusted/plugin/utility.h" |
| 35 | 36 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 bool enable_dev_interfaces() { return enable_dev_interfaces_; } | 247 bool enable_dev_interfaces() { return enable_dev_interfaces_; } |
| 247 | 248 |
| 248 Manifest const* manifest() const { return manifest_.get(); } | 249 Manifest const* manifest() const { return manifest_.get(); } |
| 249 const pp::URLUtil_Dev* url_util() const { return url_util_; } | 250 const pp::URLUtil_Dev* url_util() const { return url_util_; } |
| 250 | 251 |
| 251 int exit_status() const { return exit_status_; } | 252 int exit_status() const { return exit_status_; } |
| 252 // set_exit_status may be called off the main thread. | 253 // set_exit_status may be called off the main thread. |
| 253 void set_exit_status(int exit_status); | 254 void set_exit_status(int exit_status); |
| 254 | 255 |
| 255 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } | 256 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } |
| 257 pp::UMAPrivate& uma_interface() { return uma_interface_; } |
| 256 | 258 |
| 257 private: | 259 private: |
| 258 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); | 260 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); |
| 259 // Prevent construction and destruction from outside the class: | 261 // Prevent construction and destruction from outside the class: |
| 260 // must use factory New() method instead. | 262 // must use factory New() method instead. |
| 261 explicit Plugin(PP_Instance instance); | 263 explicit Plugin(PP_Instance instance); |
| 262 // The browser will invoke the destructor via the pp::Instance | 264 // The browser will invoke the destructor via the pp::Instance |
| 263 // pointer to this object, not from base's Delete(). | 265 // pointer to this object, not from base's Delete(). |
| 264 ~Plugin(); | 266 ~Plugin(); |
| 265 | 267 |
| 266 bool EarlyInit(int argc, const char* argn[], const char* argv[]); | 268 bool EarlyInit(int argc, const char* argn[], const char* argv[]); |
| 267 // Shuts down socket connection, service runtime, and receive thread, | 269 // Shuts down socket connection, service runtime, and receive thread, |
| 268 // in this order, for the main nacl subprocess. | 270 // in this order, for the main nacl subprocess. |
| 269 void ShutDownSubprocesses(); | 271 void ShutDownSubprocesses(); |
| 270 | 272 |
| 271 ScriptablePlugin* scriptable_plugin() const { return scriptable_plugin_; } | 273 ScriptablePlugin* scriptable_plugin() const { return scriptable_plugin_; } |
| 272 void set_scriptable_plugin(ScriptablePlugin* scriptable_plugin) { | 274 void set_scriptable_plugin(ScriptablePlugin* scriptable_plugin) { |
| 273 scriptable_plugin_ = scriptable_plugin; | 275 scriptable_plugin_ = scriptable_plugin; |
| 274 } | 276 } |
| 275 | 277 |
| 276 // Access the service runtime for the main NaCl subprocess. | 278 // Access the service runtime for the main NaCl subprocess. |
| 277 ServiceRuntime* main_service_runtime() const { | 279 ServiceRuntime* main_service_runtime() const { |
| 278 return main_subprocess_.service_runtime(); | 280 return main_subprocess_.service_runtime(); |
| 279 } | 281 } |
| 280 | 282 |
| 283 // Histogram helper functions, internal to Plugin so they can use |
| 284 // uma_interface_ normally. |
| 285 void HistogramTimeSmall(const std::string& name, int64_t ms); |
| 286 void HistogramTimeMedium(const std::string& name, int64_t ms); |
| 287 void HistogramTimeLarge(const std::string& name, int64_t ms); |
| 288 void HistogramSizeKB(const std::string& name, int32_t sample); |
| 289 void HistogramEnumerate(const std::string& name, |
| 290 int sample, |
| 291 int maximum, |
| 292 int out_of_range_replacement); |
| 293 void HistogramEnumerateOsArch(const std::string& sandbox_isa); |
| 294 void HistogramEnumerateLoadStatus(PluginErrorCode error_code, |
| 295 bool is_installed); |
| 296 void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code, |
| 297 bool is_installed); |
| 298 void HistogramEnumerateManifestIsDataURI(bool is_data_uri); |
| 299 void HistogramHTTPStatusCode(const std::string& name, int status); |
| 300 |
| 281 // Help load a nacl module, from the file specified in wrapper. | 301 // Help load a nacl module, from the file specified in wrapper. |
| 282 // This will fully initialize the |subprocess| if the load was successful. | 302 // This will fully initialize the |subprocess| if the load was successful. |
| 283 bool LoadNaClModuleCommon(nacl::DescWrapper* wrapper, | 303 bool LoadNaClModuleCommon(nacl::DescWrapper* wrapper, |
| 284 NaClSubprocess* subprocess, | 304 NaClSubprocess* subprocess, |
| 285 const Manifest* manifest, | 305 const Manifest* manifest, |
| 286 bool should_report_uma, | 306 bool should_report_uma, |
| 287 const SelLdrStartParams& params, | 307 const SelLdrStartParams& params, |
| 288 const pp::CompletionCallback& init_done_cb, | 308 const pp::CompletionCallback& init_done_cb, |
| 289 const pp::CompletionCallback& crash_cb); | 309 const pp::CompletionCallback& crash_cb); |
| 290 | 310 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 478 |
| 459 // Finds the file downloader which owns the given URL loader. This is used | 479 // Finds the file downloader which owns the given URL loader. This is used |
| 460 // in UpdateDownloadProgress to map a url loader back to the URL being | 480 // in UpdateDownloadProgress to map a url loader back to the URL being |
| 461 // downloaded. | 481 // downloaded. |
| 462 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; | 482 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; |
| 463 | 483 |
| 464 int64_t time_of_last_progress_event_; | 484 int64_t time_of_last_progress_event_; |
| 465 int exit_status_; | 485 int exit_status_; |
| 466 | 486 |
| 467 const PPB_NaCl_Private* nacl_interface_; | 487 const PPB_NaCl_Private* nacl_interface_; |
| 488 pp::UMAPrivate uma_interface_; |
| 468 }; | 489 }; |
| 469 | 490 |
| 470 } // namespace plugin | 491 } // namespace plugin |
| 471 | 492 |
| 472 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ | 493 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ |
| OLD | NEW |