OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/renderer/pepper/ppb_var_deprecated_impl.h" | 5 #include "content/renderer/pepper/ppb_var_deprecated_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "content/renderer/pepper/host_globals.h" | 9 #include "content/renderer/pepper/host_globals.h" |
10 #include "content/renderer/pepper/message_channel.h" | 10 #include "content/renderer/pepper/message_channel.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 namespace { | 34 namespace { |
35 | 35 |
36 const char kInvalidIdentifierException[] = "Error: Invalid identifier."; | 36 const char kInvalidIdentifierException[] = "Error: Invalid identifier."; |
37 const char kInvalidObjectException[] = "Error: Invalid object"; | 37 const char kInvalidObjectException[] = "Error: Invalid object"; |
38 const char kUnableToCallMethodException[] = "Error: Unable to call method"; | 38 const char kUnableToCallMethodException[] = "Error: Unable to call method"; |
39 | 39 |
40 class ObjectAccessor { | 40 class ObjectAccessor { |
41 public: | 41 public: |
42 ObjectAccessor(PP_Var var) | 42 ObjectAccessor(PP_Var var) |
43 : object_var_(V8ObjectVar::FromPPVar(var)), | 43 : object_var_(V8ObjectVar::FromPPVar(var)), |
44 instance_(object_var_ ? object_var_->instance() : NULL) { | 44 instance_(object_var_.get() ? object_var_->instance() : NULL) {} |
45 } | |
46 | 45 |
47 // Check if the object is valid. If it isn't, set an exception and return | 46 // Check if the object is valid. If it isn't, set an exception and return |
48 // false. | 47 // false. |
49 bool IsValid(PP_Var* exception) { | 48 bool IsValid(PP_Var* exception) { |
50 // If we already have an exception, then the call is invalid according to | 49 // If we already have an exception, then the call is invalid according to |
51 // the unittests. | 50 // the unittests. |
52 if (exception && exception->type != PP_VARTYPE_UNDEFINED) | 51 if (exception && exception->type != PP_VARTYPE_UNDEFINED) |
53 return false; | 52 return false; |
54 if (instance_) | 53 if (instance_) |
55 return true; | 54 return true; |
56 if (exception) | 55 if (exception) |
57 *exception = ppapi::StringVar::StringToPPVar(kInvalidObjectException); | 56 *exception = ppapi::StringVar::StringToPPVar(kInvalidObjectException); |
58 return false; | 57 return false; |
59 } | 58 } |
60 // Lazily grab the object so that the handle is created in the current handle | 59 // Lazily grab the object so that the handle is created in the current handle |
61 // scope. | 60 // scope. |
62 v8::Handle<v8::Object> GetObject() { return object_var_->GetHandle(); } | 61 v8::Handle<v8::Object> GetObject() { return object_var_->GetHandle(); } |
63 PepperPluginInstanceImpl* instance() { return instance_; } | 62 PepperPluginInstanceImpl* instance() { return instance_; } |
64 | 63 |
65 private: | 64 private: |
66 V8ObjectVar* object_var_; | 65 scoped_refptr<V8ObjectVar> object_var_; |
dcheng
2014/08/28 16:40:16
This was actually found by a second pass of the to
dcheng
2014/08/28 16:40:16
This was actually found by a second pass of the to
raymes
2014/08/29 01:12:45
The class is only stack allocated so this shouldn'
dcheng
2014/08/29 06:38:01
I've rebased and removed this diff.
| |
67 PepperPluginInstanceImpl* instance_; | 66 PepperPluginInstanceImpl* instance_; |
68 }; | 67 }; |
69 | 68 |
70 bool IsValidIdentifer(PP_Var identifier, PP_Var* exception) { | 69 bool IsValidIdentifer(PP_Var identifier, PP_Var* exception) { |
71 if (identifier.type == PP_VARTYPE_INT32 || | 70 if (identifier.type == PP_VARTYPE_INT32 || |
72 identifier.type == PP_VARTYPE_STRING) { | 71 identifier.type == PP_VARTYPE_STRING) { |
73 return true; | 72 return true; |
74 } | 73 } |
75 if (exception) | 74 if (exception) |
76 *exception = ppapi::StringVar::StringToPPVar(kInvalidIdentifierException); | 75 *exception = ppapi::StringVar::StringToPPVar(kInvalidIdentifierException); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 &CallDeprecated, | 341 &CallDeprecated, |
343 &Construct, | 342 &Construct, |
344 &IsInstanceOfDeprecated, | 343 &IsInstanceOfDeprecated, |
345 &CreateObjectDeprecated, | 344 &CreateObjectDeprecated, |
346 &CreateObjectWithModuleDeprecated, }; | 345 &CreateObjectWithModuleDeprecated, }; |
347 | 346 |
348 return &var_deprecated_interface; | 347 return &var_deprecated_interface; |
349 } | 348 } |
350 | 349 |
351 } // namespace content | 350 } // namespace content |
OLD | NEW |