OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2010 The Native Client Authors. All rights reserved. | 2 * Copyright 2010 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 // PPAPI-based implementation of the interface for a NaCl plugin instance. | 7 // PPAPI-based implementation of the interface for a NaCl plugin instance. |
8 | 8 |
9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_PLUGIN_PPAPI_H_ | 9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_PLUGIN_PPAPI_H_ |
10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_PLUGIN_PPAPI_H_ | 10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_PLUGIN_PPAPI_H_ |
(...skipping 16 matching lines...) Expand all Loading... | |
27 namespace ppapi_proxy { | 27 namespace ppapi_proxy { |
28 class BrowserPpp; | 28 class BrowserPpp; |
29 } | 29 } |
30 | 30 |
31 namespace pp { | 31 namespace pp { |
32 class URLLoader; | 32 class URLLoader; |
33 } | 33 } |
34 | 34 |
35 namespace plugin { | 35 namespace plugin { |
36 | 36 |
37 // The default MIME type for the NaCl plugin. | |
38 extern const char* const kNaClMIMEType; | |
polina
2011/04/15 22:52:11
don't you get presubmit errors for extern?
| |
39 | |
37 // Encapsulates a PPAPI NaCl plugin. | 40 // Encapsulates a PPAPI NaCl plugin. |
38 class PluginPpapi : public pp::Instance, public Plugin { | 41 class PluginPpapi : public pp::Instance, public Plugin { |
39 public: | 42 public: |
40 // Factory method for creation. | 43 // Factory method for creation. |
41 static PluginPpapi* New(PP_Instance instance); | 44 static PluginPpapi* New(PP_Instance instance); |
42 | 45 |
43 // ----- Methods inherited from pp::Instance: | 46 // ----- Methods inherited from pp::Instance: |
44 | 47 |
45 // Initializes this plugin with <embed/object ...> tag attribute count |argc|, | 48 // Initializes this plugin with <embed/object ...> tag attribute count |argc|, |
46 // names |argn| and values |argn|. Returns false on failure. | 49 // names |argn| and values |argn|. Returns false on failure. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 bool UrlAsNaClDesc(const nacl::string& url, pp::Var js_callback); | 87 bool UrlAsNaClDesc(const nacl::string& url, pp::Var js_callback); |
85 // Requests a URL asynchronously resulting in a call to pp_callback with | 88 // Requests a URL asynchronously resulting in a call to pp_callback with |
86 // a PP_Error indicating status. On success an open file descriptor | 89 // a PP_Error indicating status. On success an open file descriptor |
87 // corresponding to the url body is recorded for further lookup. | 90 // corresponding to the url body is recorded for further lookup. |
88 // This is used by SRPC-based StreamAsFile(). | 91 // This is used by SRPC-based StreamAsFile(). |
89 bool StreamAsFile(const nacl::string& url, PP_CompletionCallback pp_callback); | 92 bool StreamAsFile(const nacl::string& url, PP_CompletionCallback pp_callback); |
90 // Returns an open POSIX file descriptor retrieved by StreamAsFile() | 93 // Returns an open POSIX file descriptor retrieved by StreamAsFile() |
91 // or NACL_NO_FILE_DESC. The caller must take ownership of the descriptor. | 94 // or NACL_NO_FILE_DESC. The caller must take ownership of the descriptor. |
92 int32_t GetPOSIXFileDesc(const nacl::string& url); | 95 int32_t GetPOSIXFileDesc(const nacl::string& url); |
93 | 96 |
97 // The MIME type used to instantiate this instance of the NaCl plugin. | |
98 // Typically, the MIME type will be application/x-nacl. However, if the NEXE | |
99 // is being used as a content type handler for another content type (such as | |
100 // PDF), then this function will return that type. | |
101 const nacl::string& mime_type() const { return mime_type_; } | |
102 | |
94 private: | 103 private: |
95 NACL_DISALLOW_COPY_AND_ASSIGN(PluginPpapi); | 104 NACL_DISALLOW_COPY_AND_ASSIGN(PluginPpapi); |
96 // Prevent construction and destruction from outside the class: | 105 // Prevent construction and destruction from outside the class: |
97 // must use factory New() method instead. | 106 // must use factory New() method instead. |
98 explicit PluginPpapi(PP_Instance instance); | 107 explicit PluginPpapi(PP_Instance instance); |
99 // The browser will invoke the destructor via the pp::Instance | 108 // The browser will invoke the destructor via the pp::Instance |
100 // pointer to this object, not from base's Delete(). | 109 // pointer to this object, not from base's Delete(). |
101 virtual ~PluginPpapi(); | 110 virtual ~PluginPpapi(); |
102 | 111 |
103 // File download support. |nexe_downloader_| can be opened with a specific | 112 // File download support. |nexe_downloader_| can be opened with a specific |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 // (InitializeModule, Shutdown, and GetInterface). | 183 // (InitializeModule, Shutdown, and GetInterface). |
175 // TODO(sehr): this should be a scoped_ptr for shutdown. | 184 // TODO(sehr): this should be a scoped_ptr for shutdown. |
176 ppapi_proxy::BrowserPpp* ppapi_proxy_; | 185 ppapi_proxy::BrowserPpp* ppapi_proxy_; |
177 | 186 |
178 // If we get a DidChangeView event before the nexe is loaded, we store it and | 187 // If we get a DidChangeView event before the nexe is loaded, we store it and |
179 // replay it to nexe after it's loaded. | 188 // replay it to nexe after it's loaded. |
180 bool replayDidChangeView; | 189 bool replayDidChangeView; |
181 pp::Rect replayDidChangeViewPosition; | 190 pp::Rect replayDidChangeViewPosition; |
182 pp::Rect replayDidChangeViewClip; | 191 pp::Rect replayDidChangeViewClip; |
183 | 192 |
193 nacl::string mime_type_; | |
194 | |
184 // Keep track of the FileDownloaders created to fetch urls. | 195 // Keep track of the FileDownloaders created to fetch urls. |
185 std::set<FileDownloader*> url_downloaders_; | 196 std::set<FileDownloader*> url_downloaders_; |
186 // Keep track of file descriptors opened by StreamAsFile(). | 197 // Keep track of file descriptors opened by StreamAsFile(). |
187 // These are owned by the browser. | 198 // These are owned by the browser. |
188 std::map<nacl::string, int32_t> url_fd_map_; | 199 std::map<nacl::string, int32_t> url_fd_map_; |
189 }; | 200 }; |
190 | 201 |
191 } // namespace plugin | 202 } // namespace plugin |
192 | 203 |
193 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_PLUGIN_PPAPI_H_ | 204 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_PLUGIN_PPAPI_H_ |
OLD | NEW |