| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 265 |
| 265 // Extracts the exit status from the (main) service runtime. | 266 // Extracts the exit status from the (main) service runtime. |
| 266 int exit_status() const { | 267 int exit_status() const { |
| 267 if (NULL == main_service_runtime()) { | 268 if (NULL == main_service_runtime()) { |
| 268 return -1; | 269 return -1; |
| 269 } | 270 } |
| 270 return main_service_runtime()->exit_status(); | 271 return main_service_runtime()->exit_status(); |
| 271 } | 272 } |
| 272 | 273 |
| 273 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } | 274 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } |
| 275 const pp::UMAPrivate& uma_interface() const { return uma_interface_; } |
| 274 | 276 |
| 275 private: | 277 private: |
| 276 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); | 278 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); |
| 277 // Prevent construction and destruction from outside the class: | 279 // Prevent construction and destruction from outside the class: |
| 278 // must use factory New() method instead. | 280 // must use factory New() method instead. |
| 279 explicit Plugin(PP_Instance instance); | 281 explicit Plugin(PP_Instance instance); |
| 280 // The browser will invoke the destructor via the pp::Instance | 282 // The browser will invoke the destructor via the pp::Instance |
| 281 // pointer to this object, not from base's Delete(). | 283 // pointer to this object, not from base's Delete(). |
| 282 ~Plugin(); | 284 ~Plugin(); |
| 283 | 285 |
| 284 bool EarlyInit(int argc, const char* argn[], const char* argv[]); | 286 bool EarlyInit(int argc, const char* argn[], const char* argv[]); |
| 285 // Shuts down socket connection, service runtime, and receive thread, | 287 // Shuts down socket connection, service runtime, and receive thread, |
| 286 // in this order, for the main nacl subprocess. | 288 // in this order, for the main nacl subprocess. |
| 287 void ShutDownSubprocesses(); | 289 void ShutDownSubprocesses(); |
| 288 | 290 |
| 289 ScriptablePlugin* scriptable_plugin() const { return scriptable_plugin_; } | 291 ScriptablePlugin* scriptable_plugin() const { return scriptable_plugin_; } |
| 290 void set_scriptable_plugin(ScriptablePlugin* scriptable_plugin) { | 292 void set_scriptable_plugin(ScriptablePlugin* scriptable_plugin) { |
| 291 scriptable_plugin_ = scriptable_plugin; | 293 scriptable_plugin_ = scriptable_plugin; |
| 292 } | 294 } |
| 293 | 295 |
| 294 // Access the service runtime for the main NaCl subprocess. | 296 // Access the service runtime for the main NaCl subprocess. |
| 295 ServiceRuntime* main_service_runtime() const { | 297 ServiceRuntime* main_service_runtime() const { |
| 296 return main_subprocess_.service_runtime(); | 298 return main_subprocess_.service_runtime(); |
| 297 } | 299 } |
| 298 | 300 |
| 301 // Histogram helper functions, internal to Plugin so they can use |
| 302 // uma_interface_ normally. |
| 303 void HistogramTimeSmall(const std::string& name, int64_t ms); |
| 304 void HistogramTimeMedium(const std::string& name, int64_t ms); |
| 305 void HistogramTimeLarge(const std::string& name, int64_t ms); |
| 306 void HistogramSizeKB(const std::string& name, int32_t sample); |
| 307 void HistogramEnumerate(const std::string& name, |
| 308 int sample, |
| 309 int maximum, |
| 310 int out_of_range_replacement); |
| 311 void HistogramEnumerateOsArch(const std::string& sandbox_isa); |
| 312 void HistogramEnumerateLoadStatus(PluginErrorCode error_code, |
| 313 bool is_installed); |
| 314 void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code, |
| 315 bool is_installed); |
| 316 void HistogramEnumerateManifestIsDataURI(bool is_data_uri); |
| 317 void HistogramHTTPStatusCode(const std::string& name, int status); |
| 318 |
| 299 // Help load a nacl module, from the file specified in wrapper. | 319 // Help load a nacl module, from the file specified in wrapper. |
| 300 // This will fully initialize the |subprocess| if the load was successful. | 320 // This will fully initialize the |subprocess| if the load was successful. |
| 301 bool LoadNaClModuleCommon(nacl::DescWrapper* wrapper, | 321 bool LoadNaClModuleCommon(nacl::DescWrapper* wrapper, |
| 302 NaClSubprocess* subprocess, | 322 NaClSubprocess* subprocess, |
| 303 const Manifest* manifest, | 323 const Manifest* manifest, |
| 304 bool should_report_uma, | 324 bool should_report_uma, |
| 305 const SelLdrStartParams& params, | 325 const SelLdrStartParams& params, |
| 306 const pp::CompletionCallback& init_done_cb, | 326 const pp::CompletionCallback& init_done_cb, |
| 307 const pp::CompletionCallback& crash_cb); | 327 const pp::CompletionCallback& crash_cb); |
| 308 | 328 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 int64_t total_bytes_to_be_received); | 497 int64_t total_bytes_to_be_received); |
| 478 | 498 |
| 479 // Finds the file downloader which owns the given URL loader. This is used | 499 // Finds the file downloader which owns the given URL loader. This is used |
| 480 // in UpdateDownloadProgress to map a url loader back to the URL being | 500 // in UpdateDownloadProgress to map a url loader back to the URL being |
| 481 // downloaded. | 501 // downloaded. |
| 482 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; | 502 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const; |
| 483 | 503 |
| 484 int64_t time_of_last_progress_event_; | 504 int64_t time_of_last_progress_event_; |
| 485 | 505 |
| 486 const PPB_NaCl_Private* nacl_interface_; | 506 const PPB_NaCl_Private* nacl_interface_; |
| 507 pp::UMAPrivate uma_interface_; |
| 487 }; | 508 }; |
| 488 | 509 |
| 489 } // namespace plugin | 510 } // namespace plugin |
| 490 | 511 |
| 491 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ | 512 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ |
| OLD | NEW |