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

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

Issue 6813070: Add cross-origin loading of NEXEs for MIME type handlers (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 8 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
OLDNEW
1 // Copyright 2010 The Native Client Authors. All rights reserved. 1 // Copyright 2010 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can 2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file. 3 // be found in the LICENSE file.
4 4
5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_REMOTE_FILE_H_ 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_REMOTE_FILE_H_
6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_REMOTE_FILE_H_ 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_REMOTE_FILE_H_
7 7
8 #include "native_client/src/include/nacl_macros.h" 8 #include "native_client/src/include/nacl_macros.h"
9 #include "native_client/src/include/nacl_string.h" 9 #include "native_client/src/include/nacl_string.h"
10 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h" 10 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
11 #include "ppapi/cpp/completion_callback.h" 11 #include "ppapi/cpp/completion_callback.h"
12 #include "ppapi/cpp/dev/file_io_dev.h" 12 #include "ppapi/cpp/dev/file_io_dev.h"
13 #include "ppapi/cpp/url_loader.h" 13 #include "ppapi/cpp/url_loader.h"
14 #include "ppapi/cpp/instance.h" 14 #include "ppapi/cpp/instance.h"
15 15
16 namespace plugin { 16 namespace plugin {
17 17
18 class PluginPpapi;
19
18 // A class that wraps PPAPI URLLoader and FileIO functionality for downloading 20 // A class that wraps PPAPI URLLoader and FileIO functionality for downloading
19 // the url into a file and providing an open file descriptor. 21 // the url into a file and providing an open file descriptor.
20 class FileDownloader { 22 class FileDownloader {
21 public: 23 public:
22 // Ctor initializes |instance_| to NULL, be sure to call Initialize() before 24 // Ctor initializes |instance_| to NULL, be sure to call Initialize() before
23 // calling Open(), or Open() will fail. 25 // calling Open(), or Open() will fail.
24 FileDownloader() 26 FileDownloader()
25 : instance_(NULL), 27 : instance_(NULL),
26 file_open_notify_callback_(pp::CompletionCallback::Block()), 28 file_open_notify_callback_(pp::CompletionCallback::Block()),
27 file_io_trusted_interface_(NULL) {} 29 file_io_trusted_interface_(NULL) {}
28 ~FileDownloader() {} 30 ~FileDownloader() {}
29 31
30 // Initialize() can only be called once during the lifetime of this instance. 32 // Initialize() can only be called once during the lifetime of this instance.
31 // After the first call, subesquent calls do nothing. 33 // After the first call, subesquent calls do nothing.
32 void Initialize(pp::Instance* instance); 34 void Initialize(PluginPpapi* instance);
33 35
34 // Issues a GET on |url| downloading the response into a file. The file is 36 // Issues a GET on |url| downloading the response into a file. The file is
35 // then opened and a file descriptor is made available. Returns immediately 37 // then opened and a file descriptor is made available. Returns immediately
36 // indicating if the above steps could be scheduled asynchronously. The 38 // indicating if the above steps could be scheduled asynchronously. The
37 // |callback| will always be called with a code indicating success or failure 39 // |callback| will always be called with a code indicating success or failure
38 // of any of the steps. Fails if Initialize() has not been called. 40 // of any of the steps. Fails if Initialize() has not been called.
39 // NOTE: If you call Open() before Initialize() has been called or if the 41 // NOTE: If you call Open() before Initialize() has been called or if the
40 // FileIOTrustedInterface is not available, then |callback| will not be called 42 // FileIOTrustedInterface is not available, then |callback| will not be called
41 // and you get a false return value. 43 // and you get a false return value.
42 bool Open(const nacl::string& url, const pp::CompletionCallback& callback); 44 bool Open(const nacl::string& url, const pp::CompletionCallback& callback);
(...skipping 19 matching lines...) Expand all
62 // This class loads and opens the file in three steps: 64 // This class loads and opens the file in three steps:
63 // 1) Ask the browser to start streaming |url_| as a file. 65 // 1) Ask the browser to start streaming |url_| as a file.
64 // 2) Ask the browser to finish streaming if headers indicate success. 66 // 2) Ask the browser to finish streaming if headers indicate success.
65 // 3) Ask the browser to open the file, so we can get the file descriptor. 67 // 3) Ask the browser to open the file, so we can get the file descriptor.
66 // Each step is done asynchronously using callbacks. We create callbacks 68 // Each step is done asynchronously using callbacks. We create callbacks
67 // through a factory to take advantage of ref-counting. 69 // through a factory to take advantage of ref-counting.
68 void URLLoadStartNotify(int32_t pp_error); 70 void URLLoadStartNotify(int32_t pp_error);
69 void URLLoadFinishNotify(int32_t pp_error); 71 void URLLoadFinishNotify(int32_t pp_error);
70 void FileOpenNotify(int32_t pp_error); 72 void FileOpenNotify(int32_t pp_error);
71 73
72 pp::Instance* instance_; 74 PluginPpapi* instance_;
73 nacl::string url_to_open_; 75 nacl::string url_to_open_;
74 nacl::string url_; 76 nacl::string url_;
75 pp::CompletionCallback file_open_notify_callback_; 77 pp::CompletionCallback file_open_notify_callback_;
76 pp::FileIO_Dev file_reader_; 78 pp::FileIO_Dev file_reader_;
77 const PPB_FileIOTrusted_Dev* file_io_trusted_interface_; 79 const PPB_FileIOTrusted_Dev* file_io_trusted_interface_;
78 pp::URLLoader url_loader_; 80 pp::URLLoader url_loader_;
79 pp::CompletionCallbackFactory<FileDownloader> callback_factory_; 81 pp::CompletionCallbackFactory<FileDownloader> callback_factory_;
80 }; 82 };
81 } // namespace plugin; 83 } // namespace plugin;
82 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_REMOTE_FILE_H_ 84 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_REMOTE_FILE_H_
OLDNEW
« no previous file with comments | « no previous file | src/trusted/plugin/ppapi/file_downloader.cc » ('j') | src/trusted/plugin/ppapi/plugin_ppapi.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698