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

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

Issue 7621054: Don't use a scoped_refptr for StringVar::FromPPVar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/message_channel.cc ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.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 #include "webkit/plugins/ppapi/npapi_glue.h" 5 #include "webkit/plugins/ppapi/npapi_glue.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "webkit/plugins/ppapi/npobject_var.h" 10 #include "webkit/plugins/ppapi/npobject_var.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 case PP_VARTYPE_BOOL: 43 case PP_VARTYPE_BOOL:
44 BOOLEAN_TO_NPVARIANT(var.value.as_bool, *result); 44 BOOLEAN_TO_NPVARIANT(var.value.as_bool, *result);
45 break; 45 break;
46 case PP_VARTYPE_INT32: 46 case PP_VARTYPE_INT32:
47 INT32_TO_NPVARIANT(var.value.as_int, *result); 47 INT32_TO_NPVARIANT(var.value.as_int, *result);
48 break; 48 break;
49 case PP_VARTYPE_DOUBLE: 49 case PP_VARTYPE_DOUBLE:
50 DOUBLE_TO_NPVARIANT(var.value.as_double, *result); 50 DOUBLE_TO_NPVARIANT(var.value.as_double, *result);
51 break; 51 break;
52 case PP_VARTYPE_STRING: { 52 case PP_VARTYPE_STRING: {
53 scoped_refptr<StringVar> string(StringVar::FromPPVar(var)); 53 StringVar* string = StringVar::FromPPVar(var);
54 if (!string) { 54 if (!string) {
55 VOID_TO_NPVARIANT(*result); 55 VOID_TO_NPVARIANT(*result);
56 return false; 56 return false;
57 } 57 }
58 const std::string& value = string->value(); 58 const std::string& value = string->value();
59 char* c_string = static_cast<char*>(malloc(value.size())); 59 char* c_string = static_cast<char*>(malloc(value.size()));
60 memcpy(c_string, value.data(), value.size()); 60 memcpy(c_string, value.data(), value.size());
61 STRINGN_TO_NPVARIANT(c_string, value.size(), *result); 61 STRINGN_TO_NPVARIANT(c_string, value.size(), *result);
62 break; 62 break;
63 } 63 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 case NPVariantType_Object: 99 case NPVariantType_Object:
100 return NPObjectToPPVar(instance, NPVARIANT_TO_OBJECT(*variant)); 100 return NPObjectToPPVar(instance, NPVARIANT_TO_OBJECT(*variant));
101 } 101 }
102 NOTREACHED(); 102 NOTREACHED();
103 return PP_MakeUndefined(); 103 return PP_MakeUndefined();
104 } 104 }
105 105
106 NPIdentifier PPVarToNPIdentifier(PP_Var var) { 106 NPIdentifier PPVarToNPIdentifier(PP_Var var) {
107 switch (var.type) { 107 switch (var.type) {
108 case PP_VARTYPE_STRING: { 108 case PP_VARTYPE_STRING: {
109 scoped_refptr<StringVar> string(StringVar::FromPPVar(var)); 109 StringVar* string = StringVar::FromPPVar(var);
110 if (!string) 110 if (!string)
111 return NULL; 111 return NULL;
112 return WebBindings::getStringIdentifier(string->value().c_str()); 112 return WebBindings::getStringIdentifier(string->value().c_str());
113 } 113 }
114 case PP_VARTYPE_INT32: 114 case PP_VARTYPE_INT32:
115 return WebBindings::getIntIdentifier(var.value.as_int); 115 return WebBindings::getIntIdentifier(var.value.as_int);
116 default: 116 default:
117 return NULL; 117 return NULL;
118 } 118 }
119 } 119 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 // Call this to ignore any exception. This prevents the DCHECK from failing 211 // Call this to ignore any exception. This prevents the DCHECK from failing
212 // in the destructor. 212 // in the destructor.
213 void PPResultAndExceptionToNPResult::IgnoreException() { 213 void PPResultAndExceptionToNPResult::IgnoreException() {
214 checked_exception_ = true; 214 checked_exception_ = true;
215 } 215 }
216 216
217 // Throws the current exception to JS. The exception must be set. 217 // Throws the current exception to JS. The exception must be set.
218 void PPResultAndExceptionToNPResult::ThrowException() { 218 void PPResultAndExceptionToNPResult::ThrowException() {
219 scoped_refptr<StringVar> string(StringVar::FromPPVar(exception_)); 219 StringVar* string = StringVar::FromPPVar(exception_);
220 if (string) { 220 if (string)
221 WebBindings::setException(object_var_, string->value().c_str()); 221 WebBindings::setException(object_var_, string->value().c_str());
222 }
223 } 222 }
224 223
225 // PPVarArrayFromNPVariantArray ------------------------------------------------ 224 // PPVarArrayFromNPVariantArray ------------------------------------------------
226 225
227 PPVarArrayFromNPVariantArray::PPVarArrayFromNPVariantArray( 226 PPVarArrayFromNPVariantArray::PPVarArrayFromNPVariantArray(
228 PluginInstance* instance, 227 PluginInstance* instance,
229 size_t size, 228 size_t size,
230 const NPVariant* variants) 229 const NPVariant* variants)
231 : size_(size) { 230 : size_(size) {
232 if (size_ > 0) { 231 if (size_ > 0) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 310 }
312 } 311 }
313 312
314 // static 313 // static
315 void TryCatch::Catch(void* self, const char* message) { 314 void TryCatch::Catch(void* self, const char* message) {
316 static_cast<TryCatch*>(self)->SetException(message); 315 static_cast<TryCatch*>(self)->SetException(message);
317 } 316 }
318 317
319 } // namespace ppapi 318 } // namespace ppapi
320 } // namespace webkit 319 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/message_channel.cc ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698