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

Unified Diff: extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc

Issue 1143333008: Getting rid of more webview memory leaks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
diff --git a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
index 5a240f816a61d4918b74a06ce2caef81ee6d2b2b..dba5b6e1bcdbedbeed1c6a9d5ab83ac37fcfb3ce 100644
--- a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
+++ b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
@@ -267,26 +267,34 @@ void GuestViewInternalCustomBindings::RegisterElementResizeCallback(
void GuestViewInternalCustomBindings::RegisterView(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- // There are two parameters.
- CHECK(args.Length() == 2);
+ // There are three parameters.
+ CHECK(args.Length() == 3);
// View Instance ID.
CHECK(args[0]->IsInt32());
// View element.
CHECK(args[1]->IsObject());
+ // View type (e.g. "webview").
+ CHECK(args[2]->IsString());
// A reference to the view object is stored in |weak_view_map| using its view
// ID as the key. The reference is made weak so that it will not extend the
// lifetime of the object.
- int view_id = args[0]->Int32Value();
+ int view_instance_id = args[0]->Int32Value();
auto object =
new v8::Global<v8::Object>(args.GetIsolate(), args[1].As<v8::Object>());
- weak_view_map.Get().insert(std::make_pair(view_id, object));
+ weak_view_map.Get().insert(std::make_pair(view_instance_id, object));
- // The view_id is given to the SetWeak callback so that that view's entry in
- // |weak_view_map| can be cleared when the view object is garbage collected.
- object->SetWeak(new int(view_id),
+ // The |view_instance_id| is given to the SetWeak callback so that that view's
+ // entry in |weak_view_map| can be cleared when the view object is garbage
+ // collected.
+ object->SetWeak(new int(view_instance_id),
&GuestViewInternalCustomBindings::ResetMapEntry,
v8::WeakCallbackType::kParameter);
+
+ // Let the GuestViewManager know that a GuestView has been created.
+ const std::string& view_type = *v8::String::Utf8Value(args[2]);
+ content::RenderThread::Get()->Send(
+ new GuestViewHostMsg_ViewCreated(view_instance_id, view_type));
}
void GuestViewInternalCustomBindings::RunWithGesture(

Powered by Google App Engine
This is Rietveld 408576698