| 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_ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 class URLUtil_Dev; | 45 class URLUtil_Dev; |
| 46 } | 46 } |
| 47 | 47 |
| 48 namespace plugin { | 48 namespace plugin { |
| 49 | 49 |
| 50 class ErrorInfo; | 50 class ErrorInfo; |
| 51 class Manifest; | 51 class Manifest; |
| 52 | 52 |
| 53 class Plugin : public pp::Instance { | 53 class Plugin : public pp::Instance { |
| 54 public: | 54 public: |
| 55 // Factory method for creation. | 55 explicit Plugin(PP_Instance instance); |
| 56 static Plugin* New(PP_Instance instance); | |
| 57 | 56 |
| 58 // ----- Methods inherited from pp::Instance: | 57 // ----- Methods inherited from pp::Instance: |
| 59 | 58 |
| 60 // Initializes this plugin with <embed/object ...> tag attribute count |argc|, | 59 // Initializes this plugin with <embed/object ...> tag attribute count |argc|, |
| 61 // names |argn| and values |argn|. Returns false on failure. | 60 // names |argn| and values |argn|. Returns false on failure. |
| 62 // Gets called by the browser right after New(). | 61 // Gets called by the browser right after New(). |
| 63 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); | 62 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); |
| 64 | 63 |
| 65 // Handles document load, when the plugin is a MIME type handler. | 64 // Handles document load, when the plugin is a MIME type handler. |
| 66 virtual bool HandleDocumentLoad(const pp::URLLoader& url_loader); | 65 virtual bool HandleDocumentLoad(const pp::URLLoader& url_loader); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // contains a file descriptor. The caller must take ownership of this | 158 // contains a file descriptor. The caller must take ownership of this |
| 160 // descriptor. | 159 // descriptor. |
| 161 struct NaClFileInfo GetFileInfo(const nacl::string& url); | 160 struct NaClFileInfo GetFileInfo(const nacl::string& url); |
| 162 | 161 |
| 163 // A helper function that indicates if |url| can be requested by the document | 162 // A helper function that indicates if |url| can be requested by the document |
| 164 // under the same-origin policy. Strictly speaking, it may be possible for the | 163 // under the same-origin policy. Strictly speaking, it may be possible for the |
| 165 // document to request the URL using CORS even if this function returns false. | 164 // document to request the URL using CORS even if this function returns false. |
| 166 bool DocumentCanRequest(const std::string& url); | 165 bool DocumentCanRequest(const std::string& url); |
| 167 | 166 |
| 168 Manifest const* manifest() const { return manifest_.get(); } | 167 Manifest const* manifest() const { return manifest_.get(); } |
| 169 const pp::URLUtil_Dev* url_util() const { return url_util_; } | |
| 170 | 168 |
| 171 // set_exit_status may be called off the main thread. | 169 // set_exit_status may be called off the main thread. |
| 172 void set_exit_status(int exit_status); | 170 void set_exit_status(int exit_status); |
| 173 | 171 |
| 174 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } | 172 const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; } |
| 175 pp::UMAPrivate& uma_interface() { return uma_interface_; } | 173 pp::UMAPrivate& uma_interface() { return uma_interface_; } |
| 176 | 174 |
| 177 private: | 175 private: |
| 178 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); | 176 NACL_DISALLOW_COPY_AND_ASSIGN(Plugin); |
| 179 // Prevent construction and destruction from outside the class: | |
| 180 // must use factory New() method instead. | |
| 181 explicit Plugin(PP_Instance instance); | |
| 182 // The browser will invoke the destructor via the pp::Instance | 177 // The browser will invoke the destructor via the pp::Instance |
| 183 // pointer to this object, not from base's Delete(). | 178 // pointer to this object, not from base's Delete(). |
| 184 ~Plugin(); | 179 ~Plugin(); |
| 185 | 180 |
| 186 // Shuts down socket connection, service runtime, and receive thread, | 181 // Shuts down socket connection, service runtime, and receive thread, |
| 187 // in this order, for the main nacl subprocess. | 182 // in this order, for the main nacl subprocess. |
| 188 void ShutDownSubprocesses(); | 183 void ShutDownSubprocesses(); |
| 189 | 184 |
| 190 // Access the service runtime for the main NaCl subprocess. | 185 // Access the service runtime for the main NaCl subprocess. |
| 191 ServiceRuntime* main_service_runtime() const { | 186 ServiceRuntime* main_service_runtime() const { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 void NaClManifestFileDidOpen(int32_t pp_error); | 262 void NaClManifestFileDidOpen(int32_t pp_error); |
| 268 | 263 |
| 269 // Processes the JSON manifest string and starts loading the nexe. | 264 // Processes the JSON manifest string and starts loading the nexe. |
| 270 void ProcessNaClManifest(const nacl::string& manifest_json); | 265 void ProcessNaClManifest(const nacl::string& manifest_json); |
| 271 | 266 |
| 272 // Parses the JSON in |manifest_json| and retains a Manifest in | 267 // Parses the JSON in |manifest_json| and retains a Manifest in |
| 273 // |manifest_| for use by subsequent resource lookups. | 268 // |manifest_| for use by subsequent resource lookups. |
| 274 // On success, |true| is returned and |manifest_| is updated to | 269 // On success, |true| is returned and |manifest_| is updated to |
| 275 // contain a Manifest that is used by SelectNexeURLFromManifest. | 270 // contain a Manifest that is used by SelectNexeURLFromManifest. |
| 276 // On failure, |false| is returned, and |manifest_| is unchanged. | 271 // On failure, |false| is returned, and |manifest_| is unchanged. |
| 277 bool SetManifestObject(const nacl::string& manifest_json, | 272 bool SetManifestObject(const nacl::string& manifest_json); |
| 278 ErrorInfo* error_info); | |
| 279 | 273 |
| 280 // Logs timing information to a UMA histogram, and also logs the same timing | 274 // Logs timing information to a UMA histogram, and also logs the same timing |
| 281 // information divided by the size of the nexe to another histogram. | 275 // information divided by the size of the nexe to another histogram. |
| 282 void HistogramStartupTimeSmall(const std::string& name, float dt); | 276 void HistogramStartupTimeSmall(const std::string& name, float dt); |
| 283 void HistogramStartupTimeMedium(const std::string& name, float dt); | 277 void HistogramStartupTimeMedium(const std::string& name, float dt); |
| 284 | 278 |
| 285 // Callback used when loading a URL for SRPC-based StreamAsFile(). | 279 // Callback used when loading a URL for SRPC-based StreamAsFile(). |
| 286 void UrlDidOpenForStreamAsFile(int32_t pp_error, | 280 void UrlDidOpenForStreamAsFile(int32_t pp_error, |
| 287 FileDownloader* url_downloader, | 281 FileDownloader* url_downloader, |
| 288 pp::CompletionCallback pp_callback); | 282 pp::CompletionCallback pp_callback); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 307 // multiple GETs that might arrive out of order. For example, this will | 301 // multiple GETs that might arrive out of order. For example, this will |
| 308 // prevent a GET of a NaCl manifest while a .nexe GET is pending. Note that | 302 // prevent a GET of a NaCl manifest while a .nexe GET is pending. Note that |
| 309 // this will also prevent simultaneous handling of multiple .nexes on a page. | 303 // this will also prevent simultaneous handling of multiple .nexes on a page. |
| 310 FileDownloader nexe_downloader_; | 304 FileDownloader nexe_downloader_; |
| 311 pp::CompletionCallbackFactory<Plugin> callback_factory_; | 305 pp::CompletionCallbackFactory<Plugin> callback_factory_; |
| 312 | 306 |
| 313 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; | 307 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; |
| 314 | 308 |
| 315 // The manifest dictionary. Used for looking up resources to be loaded. | 309 // The manifest dictionary. Used for looking up resources to be loaded. |
| 316 nacl::scoped_ptr<Manifest> manifest_; | 310 nacl::scoped_ptr<Manifest> manifest_; |
| 317 // URL processing interface for use in looking up resources in manifests. | |
| 318 const pp::URLUtil_Dev* url_util_; | |
| 319 | 311 |
| 320 // Keep track of the FileDownloaders created to fetch urls. | 312 // Keep track of the FileDownloaders created to fetch urls. |
| 321 std::set<FileDownloader*> url_downloaders_; | 313 std::set<FileDownloader*> url_downloaders_; |
| 322 // Keep track of file descriptors opened by StreamAsFile(). | 314 // Keep track of file descriptors opened by StreamAsFile(). |
| 323 // These are owned by the browser. | 315 // These are owned by the browser. |
| 324 std::map<nacl::string, NaClFileInfoAutoCloser*> url_file_info_map_; | 316 std::map<nacl::string, NaClFileInfoAutoCloser*> url_file_info_map_; |
| 325 | 317 |
| 326 // Callback to receive .nexe and .dso download progress notifications. | 318 // Callback to receive .nexe and .dso download progress notifications. |
| 327 static void UpdateDownloadProgress( | 319 static void UpdateDownloadProgress( |
| 328 PP_Instance pp_instance, | 320 PP_Instance pp_instance, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 344 int64_t manifest_open_time_; | 336 int64_t manifest_open_time_; |
| 345 int64_t nexe_open_time_; | 337 int64_t nexe_open_time_; |
| 346 | 338 |
| 347 const PPB_NaCl_Private* nacl_interface_; | 339 const PPB_NaCl_Private* nacl_interface_; |
| 348 pp::UMAPrivate uma_interface_; | 340 pp::UMAPrivate uma_interface_; |
| 349 }; | 341 }; |
| 350 | 342 |
| 351 } // namespace plugin | 343 } // namespace plugin |
| 352 | 344 |
| 353 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ | 345 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ |
| OLD | NEW |