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

Side by Side Diff: webkit/plugins/ppapi/npapi_glue.h

Issue 8826011: Remove PP_Module from parameters for PPB_Var.VarFromUtf8. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years 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
« no previous file with comments | « webkit/plugins/ppapi/message_channel.cc ('k') | webkit/plugins/ppapi/npapi_glue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_PLUGINS_PPAPI_NPAPI_GLUE_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_NPAPI_GLUE_H_
6 #define WEBKIT_PLUGINS_PPAPI_NPAPI_GLUE_H_ 6 #define WEBKIT_PLUGINS_PPAPI_NPAPI_GLUE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ppapi/c/pp_module.h" 10 #include "ppapi/c/pp_module.h"
(...skipping 29 matching lines...) Expand all
40 // the reference to the caller. This is suitable for returning to a plugin. 40 // the reference to the caller. This is suitable for returning to a plugin.
41 WEBKIT_PLUGINS_EXPORT PP_Var NPVariantToPPVar(PluginInstance* instance, 41 WEBKIT_PLUGINS_EXPORT PP_Var NPVariantToPPVar(PluginInstance* instance,
42 const NPVariant* variant); 42 const NPVariant* variant);
43 43
44 // Returns a NPIdentifier that corresponds to the given PP_Var. The contents 44 // Returns a NPIdentifier that corresponds to the given PP_Var. The contents
45 // of the PP_Var will be copied. Returns 0 if the given PP_Var is not a a 45 // of the PP_Var will be copied. Returns 0 if the given PP_Var is not a a
46 // string or integer type. 46 // string or integer type.
47 NPIdentifier PPVarToNPIdentifier(PP_Var var); 47 NPIdentifier PPVarToNPIdentifier(PP_Var var);
48 48
49 // Returns a PP_Var corresponding to the given identifier. In the case of 49 // Returns a PP_Var corresponding to the given identifier. In the case of
50 // a string identifier, the string will be allocated associated with the 50 // a string identifier, the returned string will have a reference count of 1.
51 // given module. A returned string will have a reference count of 1. 51 PP_Var NPIdentifierToPPVar(NPIdentifier id);
52 PP_Var NPIdentifierToPPVar(PP_Module module, NPIdentifier id);
53 52
54 // Helper function to create a PP_Var of type object that contains the given 53 // Helper function to create a PP_Var of type object that contains the given
55 // NPObject for use byt he given module. Calling this function multiple times 54 // NPObject for use byt he given module. Calling this function multiple times
56 // given the same module + NPObject results in the same PP_Var, assuming that 55 // given the same module + NPObject results in the same PP_Var, assuming that
57 // there is still a PP_Var with a reference open to it from the previous 56 // there is still a PP_Var with a reference open to it from the previous
58 // call. 57 // call.
59 // 58 //
60 // The module is necessary because we can have different modules pointing to 59 // The instance is necessary because we can have different instances pointing to
61 // the same NPObject, and we want to keep their refs separate. 60 // the same NPObject, and we want to keep their refs separate.
62 // 61 //
63 // If no ObjectVar currently exists corresponding to the NPObject, one is 62 // If no ObjectVar currently exists corresponding to the NPObject, one is
64 // created associated with the given module. 63 // created associated with the given module.
65 // 64 //
66 // Note: this could easily be changed to take a PP_Instance instead if that 65 // Note: this could easily be changed to take a PP_Instance instead if that
67 // makes certain calls in the future easier. Currently all callers have a 66 // makes certain calls in the future easier. Currently all callers have a
68 // PluginInstance so that's what we use here. 67 // PluginInstance so that's what we use here.
69 WEBKIT_PLUGINS_EXPORT PP_Var NPObjectToPPVar(PluginInstance* instance, 68 WEBKIT_PLUGINS_EXPORT PP_Var NPObjectToPPVar(PluginInstance* instance,
70 NPObject* object); 69 NPObject* object);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 223
225 // TryCatch -------------------------------------------------------------------- 224 // TryCatch --------------------------------------------------------------------
226 225
227 // Instantiate this object on the stack to catch V8 exceptions and pass them 226 // Instantiate this object on the stack to catch V8 exceptions and pass them
228 // to an optional out parameter supplied by the plugin. 227 // to an optional out parameter supplied by the plugin.
229 class TryCatch { 228 class TryCatch {
230 public: 229 public:
231 // The given exception may be NULL if the consumer isn't interested in 230 // The given exception may be NULL if the consumer isn't interested in
232 // catching exceptions. If non-NULL, the given var will be updated if any 231 // catching exceptions. If non-NULL, the given var will be updated if any
233 // exception is thrown (so it must outlive the TryCatch object). 232 // exception is thrown (so it must outlive the TryCatch object).
234 // 233 TryCatch(PP_Var* exception);
235 // The module associated with the exception is passed so we know which module
236 // to associate any exception string with. It may be NULL if you don't know
237 // the module at construction time, in which case you should set it later
238 // by calling set_module().
239 //
240 // If an exception is thrown when the module is NULL, setting *any* exception
241 // will result in using the InvalidObjectException.
242 TryCatch(PP_Module module, PP_Var* exception);
243 ~TryCatch(); 234 ~TryCatch();
244 235
245 // Get and set the module. This may be NULL (see the constructor).
246 PP_Module pp_module() { return pp_module_; }
247 void set_pp_module(PP_Module module) { pp_module_ = module; }
248
249 // Returns true is an exception has been thrown. This can be true immediately 236 // Returns true is an exception has been thrown. This can be true immediately
250 // after construction if the var passed to the constructor is non-void. 237 // after construction if the var passed to the constructor is non-void.
251 bool has_exception() const { return has_exception_; } 238 bool has_exception() const { return has_exception_; }
252 239
253 // Sets the given exception. If no module has been set yet, the message will 240 // Sets the given exception. If an exception has been previously set, this
254 // be ignored (since we have no module to associate the string with) and the 241 // function will do nothing (normally you want only the first exception).
255 // SetInvalidObjectException() will be used instead.
256 //
257 // If an exception has been previously set, this function will do nothing
258 // (normally you want only the first exception).
259 void SetException(const char* message); 242 void SetException(const char* message);
260 243
261 // Sets the exception to be a generic message contained in a magic string
262 // not associated with any module.
263 void SetInvalidObjectException();
264
265 private: 244 private:
266 static void Catch(void* self, const char* message); 245 static void Catch(void* self, const char* message);
267 246
268 PP_Module pp_module_;
269
270 // True if an exception has been thrown. Since the exception itself may be 247 // True if an exception has been thrown. Since the exception itself may be
271 // NULL if the plugin isn't interested in getting the exception, this will 248 // NULL if the plugin isn't interested in getting the exception, this will
272 // always indicate if SetException has been called, regardless of whether 249 // always indicate if SetException has been called, regardless of whether
273 // the exception itself has been stored. 250 // the exception itself has been stored.
274 bool has_exception_; 251 bool has_exception_;
275 252
276 // May be null if the consumer isn't interesting in catching exceptions. 253 // May be null if the consumer isn't interesting in catching exceptions.
277 PP_Var* exception_; 254 PP_Var* exception_;
278 }; 255 };
279 256
280 } // namespace ppapi 257 } // namespace ppapi
281 } // namespace webkit 258 } // namespace webkit
282 259
283 #endif // WEBKIT_PLUGINS_PPAPI_NPAPI_GLUE_H_ 260 #endif // WEBKIT_PLUGINS_PPAPI_NPAPI_GLUE_H_
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/message_channel.cc ('k') | webkit/plugins/ppapi/npapi_glue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698