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 // TODO(abarth): This declaration should be in a more general location so it | |
39 // can be shared with the NPAPI code. | |
polina
2011/04/15 06:24:57
what NPAPI code?
abarth-chromium
2011/04/15 06:36:40
Ah, I'm working against an old version of the plug
| |
40 extern const char* const kNaClMIMEType; | |
41 | |
37 // Encapsulates a PPAPI NaCl plugin. | 42 // Encapsulates a PPAPI NaCl plugin. |
38 class PluginPpapi : public pp::Instance, public Plugin { | 43 class PluginPpapi : public pp::Instance, public Plugin { |
39 public: | 44 public: |
40 // Factory method for creation. | 45 // Factory method for creation. |
41 static PluginPpapi* New(PP_Instance instance); | 46 static PluginPpapi* New(PP_Instance instance); |
42 | 47 |
43 // ----- Methods inherited from pp::Instance: | 48 // ----- Methods inherited from pp::Instance: |
44 | 49 |
45 // Initializes this plugin with <embed/object ...> tag attribute count |argc|, | 50 // Initializes this plugin with <embed/object ...> tag attribute count |argc|, |
46 // names |argn| and values |argn|. Returns false on failure. | 51 // 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); | 89 bool UrlAsNaClDesc(const nacl::string& url, pp::Var js_callback); |
85 // Requests a URL asynchronously resulting in a call to pp_callback with | 90 // Requests a URL asynchronously resulting in a call to pp_callback with |
86 // a PP_Error indicating status. On success an open file descriptor | 91 // a PP_Error indicating status. On success an open file descriptor |
87 // corresponding to the url body is recorded for further lookup. | 92 // corresponding to the url body is recorded for further lookup. |
88 // This is used by SRPC-based StreamAsFile(). | 93 // This is used by SRPC-based StreamAsFile(). |
89 bool StreamAsFile(const nacl::string& url, PP_CompletionCallback pp_callback); | 94 bool StreamAsFile(const nacl::string& url, PP_CompletionCallback pp_callback); |
90 // Returns an open POSIX file descriptor retrieved by StreamAsFile() | 95 // Returns an open POSIX file descriptor retrieved by StreamAsFile() |
91 // or NACL_NO_FILE_DESC. The caller must take ownership of the descriptor. | 96 // or NACL_NO_FILE_DESC. The caller must take ownership of the descriptor. |
92 int32_t GetPOSIXFileDesc(const nacl::string& url); | 97 int32_t GetPOSIXFileDesc(const nacl::string& url); |
93 | 98 |
99 // The MIME type used to instantiate this instance of the NaCl plugin. | |
100 // Typically, the MIME type will be application/x-nacl. However, if the NEXE | |
101 // is being used as a content type handler for another content type (such as | |
102 // PDF), then this function will return that type. | |
103 const std::string& mime_type() const { return mime_type_; } | |
polina
2011/04/15 06:24:57
we use nacl::string
abarth-chromium
2011/04/15 06:36:40
Done.
| |
104 | |
94 private: | 105 private: |
95 NACL_DISALLOW_COPY_AND_ASSIGN(PluginPpapi); | 106 NACL_DISALLOW_COPY_AND_ASSIGN(PluginPpapi); |
96 // Prevent construction and destruction from outside the class: | 107 // Prevent construction and destruction from outside the class: |
97 // must use factory New() method instead. | 108 // must use factory New() method instead. |
98 explicit PluginPpapi(PP_Instance instance); | 109 explicit PluginPpapi(PP_Instance instance); |
99 // The browser will invoke the destructor via the pp::Instance | 110 // The browser will invoke the destructor via the pp::Instance |
100 // pointer to this object, not from base's Delete(). | 111 // pointer to this object, not from base's Delete(). |
101 virtual ~PluginPpapi(); | 112 virtual ~PluginPpapi(); |
102 | 113 |
103 // File download support. |nexe_downloader_| can be opened with a specific | 114 // 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). | 185 // (InitializeModule, Shutdown, and GetInterface). |
175 // TODO(sehr): this should be a scoped_ptr for shutdown. | 186 // TODO(sehr): this should be a scoped_ptr for shutdown. |
176 ppapi_proxy::BrowserPpp* ppapi_proxy_; | 187 ppapi_proxy::BrowserPpp* ppapi_proxy_; |
177 | 188 |
178 // If we get a DidChangeView event before the nexe is loaded, we store it and | 189 // If we get a DidChangeView event before the nexe is loaded, we store it and |
179 // replay it to nexe after it's loaded. | 190 // replay it to nexe after it's loaded. |
180 bool replayDidChangeView; | 191 bool replayDidChangeView; |
181 pp::Rect replayDidChangeViewPosition; | 192 pp::Rect replayDidChangeViewPosition; |
182 pp::Rect replayDidChangeViewClip; | 193 pp::Rect replayDidChangeViewClip; |
183 | 194 |
195 std::string mime_type_; | |
196 | |
184 // Keep track of the FileDownloaders created to fetch urls. | 197 // Keep track of the FileDownloaders created to fetch urls. |
185 std::set<FileDownloader*> url_downloaders_; | 198 std::set<FileDownloader*> url_downloaders_; |
186 // Keep track of file descriptors opened by StreamAsFile(). | 199 // Keep track of file descriptors opened by StreamAsFile(). |
187 // These are owned by the browser. | 200 // These are owned by the browser. |
188 std::map<nacl::string, int32_t> url_fd_map_; | 201 std::map<nacl::string, int32_t> url_fd_map_; |
189 }; | 202 }; |
190 | 203 |
191 } // namespace plugin | 204 } // namespace plugin |
192 | 205 |
193 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_PLUGIN_PPAPI_H_ | 206 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PPAPI_PLUGIN_PPAPI_H_ |
OLD | NEW |