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

Side by Side Diff: content/renderer/pepper/plugin_object.cc

Issue 1805303002: Ensure that the ppp_class_data is freed when a PluginObject isn't created (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | 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 "content/renderer/pepper/plugin_object.h" 5 #include "content/renderer/pepper/plugin_object.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // static 72 // static
73 PP_Var PluginObject::Create(PepperPluginInstanceImpl* instance, 73 PP_Var PluginObject::Create(PepperPluginInstanceImpl* instance,
74 const PPP_Class_Deprecated* ppp_class, 74 const PPP_Class_Deprecated* ppp_class,
75 void* ppp_class_data) { 75 void* ppp_class_data) {
76 V8VarConverter var_converter(instance->pp_instance(), 76 V8VarConverter var_converter(instance->pp_instance(),
77 V8VarConverter::kAllowObjectVars); 77 V8VarConverter::kAllowObjectVars);
78 PepperTryCatchVar try_catch(instance, &var_converter, NULL); 78 PepperTryCatchVar try_catch(instance, &var_converter, NULL);
79 // If the V8 context is empty, we may be in the process of tearing down the 79 // If the V8 context is empty, we may be in the process of tearing down the
80 // frame and may not have a valid isolate (in particular due to re-entrancy). 80 // frame and may not have a valid isolate (in particular due to re-entrancy).
81 // We shouldn't try to call gin::CreateHandle. 81 // We shouldn't try to call gin::CreateHandle.
82 if (try_catch.GetContext().IsEmpty()) 82 if (try_catch.GetContext().IsEmpty()) {
83 ppp_class->Deallocate(ppp_class_data);
83 return PP_MakeUndefined(); 84 return PP_MakeUndefined();
85 }
84 gin::Handle<PluginObject> object = 86 gin::Handle<PluginObject> object =
85 gin::CreateHandle(instance->GetIsolate(), 87 gin::CreateHandle(instance->GetIsolate(),
86 new PluginObject(instance, ppp_class, ppp_class_data)); 88 new PluginObject(instance, ppp_class, ppp_class_data));
87 ScopedPPVar result = try_catch.FromV8(object.ToV8()); 89 ScopedPPVar result = try_catch.FromV8(object.ToV8());
88 DCHECK(!try_catch.HasException()); 90 DCHECK(!try_catch.HasException());
89 return result.Release(); 91 return result.Release();
90 } 92 }
91 93
92 v8::Local<v8::Value> PluginObject::GetNamedProperty( 94 v8::Local<v8::Value> PluginObject::GetNamedProperty(
93 v8::Isolate* isolate, 95 v8::Isolate* isolate,
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return function_template; 283 return function_template;
282 function_template = 284 function_template =
283 gin::CreateFunctionTemplate( 285 gin::CreateFunctionTemplate(
284 isolate, base::Bind(&PluginObject::Call, weak_factory_.GetWeakPtr(), 286 isolate, base::Bind(&PluginObject::Call, weak_factory_.GetWeakPtr(),
285 name)); 287 name));
286 template_cache_.Set(name, function_template); 288 template_cache_.Set(name, function_template);
287 return function_template; 289 return function_template;
288 } 290 }
289 291
290 } // namespace content 292 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698