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

Side by Side Diff: content/plugin/webplugin_delegate_stub.cc

Issue 17208003: Track NPObject ownership by the originating plugins' NPP identifier. [4/6] (Chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove DCHECKs on proxy and stub maps. Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/plugin/plugin_channel.cc ('k') | content/plugin/webplugin_proxy.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) 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/plugin/webplugin_delegate_stub.h" 5 #include "content/plugin/webplugin_delegate_stub.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 22 matching lines...) Expand all
33 namespace content { 33 namespace content {
34 34
35 static void DestroyWebPluginAndDelegate( 35 static void DestroyWebPluginAndDelegate(
36 base::WeakPtr<NPObjectStub> scriptable_object, 36 base::WeakPtr<NPObjectStub> scriptable_object,
37 webkit::npapi::WebPluginDelegateImpl* delegate, 37 webkit::npapi::WebPluginDelegateImpl* delegate,
38 WebPlugin* webplugin) { 38 WebPlugin* webplugin) {
39 // The plugin may not expect us to try to release the scriptable object 39 // The plugin may not expect us to try to release the scriptable object
40 // after calling NPP_Destroy on the instance, so delete the stub now. 40 // after calling NPP_Destroy on the instance, so delete the stub now.
41 if (scriptable_object.get()) 41 if (scriptable_object.get())
42 scriptable_object->DeleteSoon(); 42 scriptable_object->DeleteSoon();
43
44 // Un-register the plugin instance as an object owner.
45 WebBindings::unregisterObjectOwner(delegate->GetPluginNPP());
46
43 // WebPlugin must outlive WebPluginDelegate. 47 // WebPlugin must outlive WebPluginDelegate.
44 if (delegate) 48 if (delegate)
45 delegate->PluginDestroyed(); 49 delegate->PluginDestroyed();
46 50
47 delete webplugin; 51 delete webplugin;
48 } 52 }
49 53
50 WebPluginDelegateStub::WebPluginDelegateStub( 54 WebPluginDelegateStub::WebPluginDelegateStub(
51 const std::string& mime_type, int instance_id, PluginChannel* channel) : 55 const std::string& mime_type, int instance_id, PluginChannel* channel) :
52 mime_type_(mime_type), 56 mime_type_(mime_type),
(...skipping 16 matching lines...) Expand all
69 FROM_HERE, 73 FROM_HERE,
70 base::Bind(&DestroyWebPluginAndDelegate, 74 base::Bind(&DestroyWebPluginAndDelegate,
71 plugin_scriptable_object_, 75 plugin_scriptable_object_,
72 delegate_, 76 delegate_,
73 webplugin_)); 77 webplugin_));
74 } else { 78 } else {
75 // Safe to delete right away. 79 // Safe to delete right away.
76 DestroyWebPluginAndDelegate( 80 DestroyWebPluginAndDelegate(
77 plugin_scriptable_object_, delegate_, webplugin_); 81 plugin_scriptable_object_, delegate_, webplugin_);
78 } 82 }
83
84 // Remove the NPObject owner mapping for this instance.
85 channel_->RemoveMappingForNPObjectOwner(instance_id_);
79 } 86 }
80 87
81 bool WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { 88 bool WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) {
82 GetContentClient()->SetActiveURL(page_url_); 89 GetContentClient()->SetActiveURL(page_url_);
83 90
84 // A plugin can execute a script to delete itself in any of its NPP methods. 91 // A plugin can execute a script to delete itself in any of its NPP methods.
85 // Hold an extra reference to ourself so that if this does occur and we're 92 // Hold an extra reference to ourself so that if this does occur and we're
86 // handling a sync message, we don't crash when attempting to send a reply. 93 // handling a sync message, we don't crash when attempting to send a reply.
87 // The exception to this is when we're already in the destructor. 94 // The exception to this is when we're already in the destructor.
88 if (!in_destructor_) 95 if (!in_destructor_)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 webplugin_ = new WebPluginProxy(channel_.get(), 175 webplugin_ = new WebPluginProxy(channel_.get(),
169 instance_id_, 176 instance_id_,
170 page_url_, 177 page_url_,
171 params.host_render_view_routing_id); 178 params.host_render_view_routing_id);
172 delegate_ = webkit::npapi::WebPluginDelegateImpl::Create(path, mime_type_); 179 delegate_ = webkit::npapi::WebPluginDelegateImpl::Create(path, mime_type_);
173 if (delegate_) { 180 if (delegate_) {
174 webplugin_->set_delegate(delegate_); 181 webplugin_->set_delegate(delegate_);
175 std::vector<std::string> arg_names = params.arg_names; 182 std::vector<std::string> arg_names = params.arg_names;
176 std::vector<std::string> arg_values = params.arg_values; 183 std::vector<std::string> arg_values = params.arg_values;
177 184
185 // Register the plugin as a valid object owner.
186 WebBindings::registerObjectOwner(delegate_->GetPluginNPP());
187
188 // Add an NPObject owner mapping for this instance, to support ownership
189 // tracking in the renderer.
190 channel_->AddMappingForNPObjectOwner(instance_id_,
191 delegate_->GetPluginNPP());
192
178 *result = delegate_->Initialize(params.url, 193 *result = delegate_->Initialize(params.url,
179 arg_names, 194 arg_names,
180 arg_values, 195 arg_values,
181 webplugin_, 196 webplugin_,
182 params.load_manually); 197 params.load_manually);
183 *transparent = delegate_->instance()->transparent(); 198 *transparent = delegate_->instance()->transparent();
184 } 199 }
185 } 200 }
186 201
187 void WebPluginDelegateStub::OnWillSendRequest(int id, const GURL& url, 202 void WebPluginDelegateStub::OnWillSendRequest(int id, const GURL& url,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } 407 }
393 408
394 void WebPluginDelegateStub::OnHTTPRangeRequestReply( 409 void WebPluginDelegateStub::OnHTTPRangeRequestReply(
395 unsigned long resource_id, int range_request_id) { 410 unsigned long resource_id, int range_request_id) {
396 WebPluginResourceClient* resource_client = 411 WebPluginResourceClient* resource_client =
397 delegate_->CreateSeekableResourceClient(resource_id, range_request_id); 412 delegate_->CreateSeekableResourceClient(resource_id, range_request_id);
398 webplugin_->OnResourceCreated(resource_id, resource_client); 413 webplugin_->OnResourceCreated(resource_id, resource_client);
399 } 414 }
400 415
401 } // namespace content 416 } // namespace content
OLDNEW
« no previous file with comments | « content/plugin/plugin_channel.cc ('k') | content/plugin/webplugin_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698