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

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

Issue 294633003: Pepper: Move StreamAsFile out of trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes for bbudge Created 6 years, 7 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 class CompletionCallback; 43 class CompletionCallback;
44 class URLLoader; 44 class URLLoader;
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 int32_t ConvertFileDescriptor(PP_FileHandle handle);
54
53 class Plugin : public pp::Instance { 55 class Plugin : public pp::Instance {
54 public: 56 public:
55 explicit Plugin(PP_Instance instance); 57 explicit Plugin(PP_Instance instance);
56 58
57 // ----- Methods inherited from pp::Instance: 59 // ----- Methods inherited from pp::Instance:
58 60
59 // Initializes this plugin with <embed/object ...> tag attribute count |argc|, 61 // Initializes this plugin with <embed/object ...> tag attribute count |argc|,
60 // names |argn| and values |argn|. Returns false on failure. 62 // names |argn| and values |argn|. Returns false on failure.
61 // Gets called by the browser right after New(). 63 // Gets called by the browser right after New().
62 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); 64 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 143
142 nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; } 144 nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; }
143 145
144 // Requests a NaCl manifest download from a |url| relative to the page origin. 146 // Requests a NaCl manifest download from a |url| relative to the page origin.
145 void RequestNaClManifest(const nacl::string& url); 147 void RequestNaClManifest(const nacl::string& url);
146 148
147 // Called back by CallOnMainThread. Dispatches the first enqueued progress 149 // Called back by CallOnMainThread. Dispatches the first enqueued progress
148 // event. 150 // event.
149 void DispatchProgressEvent(int32_t result); 151 void DispatchProgressEvent(int32_t result);
150 152
151 // Requests a URL asynchronously resulting in a call to pp_callback with 153 // Requests a URL asynchronously, resulting in a call to |callback| with
152 // a PP_Error indicating status. 154 // an error code indicating status. On success, writes file information to
153 bool StreamAsFile(const nacl::string& url, 155 // |file_info|.
154 NaClFileInfo *out_file_info, 156 void StreamAsFile(const nacl::string& url,
157 PP_NaClFileInfo* file_info,
155 const pp::CompletionCallback& callback); 158 const pp::CompletionCallback& callback);
156 159
157 // A helper function that indicates if |url| can be requested by the document 160 // A helper function that indicates if |url| can be requested by the document
158 // under the same-origin policy. Strictly speaking, it may be possible for the 161 // under the same-origin policy. Strictly speaking, it may be possible for the
159 // document to request the URL using CORS even if this function returns false. 162 // document to request the URL using CORS even if this function returns false.
160 bool DocumentCanRequest(const std::string& url); 163 bool DocumentCanRequest(const std::string& url);
161 164
162 // set_exit_status may be called off the main thread. 165 // set_exit_status may be called off the main thread.
163 void set_exit_status(int exit_status); 166 void set_exit_status(int exit_status);
164 167
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 void NaClManifestFileDidOpen(int32_t pp_error); 243 void NaClManifestFileDidOpen(int32_t pp_error);
241 244
242 // Processes the JSON manifest string and starts loading the nexe. 245 // Processes the JSON manifest string and starts loading the nexe.
243 void ProcessNaClManifest(const nacl::string& manifest_json); 246 void ProcessNaClManifest(const nacl::string& manifest_json);
244 247
245 // Logs timing information to a UMA histogram, and also logs the same timing 248 // Logs timing information to a UMA histogram, and also logs the same timing
246 // information divided by the size of the nexe to another histogram. 249 // information divided by the size of the nexe to another histogram.
247 void HistogramStartupTimeSmall(const std::string& name, float dt); 250 void HistogramStartupTimeSmall(const std::string& name, float dt);
248 void HistogramStartupTimeMedium(const std::string& name, float dt); 251 void HistogramStartupTimeMedium(const std::string& name, float dt);
249 252
250 // Callback used when loading a URL for SRPC-based StreamAsFile().
251 void UrlDidOpenForStreamAsFile(int32_t pp_error,
252 FileDownloader* url_downloader,
253 NaClFileInfo* out_file_info,
254 pp::CompletionCallback pp_callback);
255
256 // Open an app file by requesting a file descriptor from the browser. This
257 // method first checks that the url is for an installed file before making the
258 // request so it won't slow down non-installed file downloads.
259 bool OpenURLFast(const nacl::string& url, FileDownloader* downloader);
260
261 void SetExitStatusOnMainThread(int32_t pp_error, int exit_status); 253 void SetExitStatusOnMainThread(int32_t pp_error, int exit_status);
262 254
263 // Keep track of the NaCl module subprocess that was spun up in the plugin. 255 // Keep track of the NaCl module subprocess that was spun up in the plugin.
264 NaClSubprocess main_subprocess_; 256 NaClSubprocess main_subprocess_;
265 257
266 bool uses_nonsfi_mode_; 258 bool uses_nonsfi_mode_;
267 259
268 nacl::DescWrapperFactory* wrapper_factory_; 260 nacl::DescWrapperFactory* wrapper_factory_;
269 261
270 // Original, unresolved URL for the .nexe program to load. 262 // Original, unresolved URL for the .nexe program to load.
271 std::string program_url_; 263 std::string program_url_;
272 264
273 pp::CompletionCallbackFactory<Plugin> callback_factory_; 265 pp::CompletionCallbackFactory<Plugin> callback_factory_;
274 266
275 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; 267 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_;
276 268
277 // Keep track of the FileDownloaders created to fetch urls.
278 std::set<FileDownloader*> url_downloaders_;
279
280 // Callback to receive .nexe and .dso download progress notifications.
281 static void UpdateDownloadProgress(
282 PP_Instance pp_instance,
283 PP_Resource pp_resource,
284 int64_t bytes_sent,
285 int64_t total_bytes_to_be_sent,
286 int64_t bytes_received,
287 int64_t total_bytes_to_be_received);
288
289 // Finds the file downloader which owns the given URL loader. This is used
290 // in UpdateDownloadProgress to map a url loader back to the URL being
291 // downloaded.
292 const FileDownloader* FindFileDownloader(PP_Resource url_loader) const;
293
294 int64_t time_of_last_progress_event_; 269 int64_t time_of_last_progress_event_;
295 int exit_status_; 270 int exit_status_;
296 271
297 int32_t manifest_id_; 272 int32_t manifest_id_;
298 273
299 PP_FileHandle nexe_handle_; 274 PP_FileHandle nexe_handle_;
300 uint64_t nexe_token_lo_; 275 uint64_t nexe_token_lo_;
301 uint64_t nexe_token_hi_; 276 uint64_t nexe_token_hi_;
302 277
303 const PPB_NaCl_Private* nacl_interface_; 278 const PPB_NaCl_Private* nacl_interface_;
304 pp::UMAPrivate uma_interface_; 279 pp::UMAPrivate uma_interface_;
305 }; 280 };
306 281
307 } // namespace plugin 282 } // namespace plugin
308 283
309 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_ 284 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PLUGIN_H_
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/file_downloader.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