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

Side by Side Diff: content/renderer/webplugin_delegate_proxy.cc

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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/renderer/skia_benchmarking_extension.cc ('k') | content/shell/shell_browser_context.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/renderer/webplugin_delegate_proxy.h" 5 #include "content/renderer/webplugin_delegate_proxy.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #elif defined(USE_X11) 9 #elif defined(USE_X11)
10 #include <cairo/cairo.h> 10 #include <cairo/cairo.h>
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void InitializeForSeekableStream(unsigned long resource_id, 118 void InitializeForSeekableStream(unsigned long resource_id,
119 int range_request_id) { 119 int range_request_id) {
120 resource_id_ = resource_id; 120 resource_id_ = resource_id;
121 multibyte_response_expected_ = true; 121 multibyte_response_expected_ = true;
122 channel_->Send(new PluginMsg_HTTPRangeRequestReply( 122 channel_->Send(new PluginMsg_HTTPRangeRequestReply(
123 instance_id_, resource_id, range_request_id)); 123 instance_id_, resource_id, range_request_id));
124 } 124 }
125 125
126 // PluginResourceClient implementation: 126 // PluginResourceClient implementation:
127 virtual void WillSendRequest(const GURL& url, int http_status_code) OVERRIDE { 127 virtual void WillSendRequest(const GURL& url, int http_status_code) OVERRIDE {
128 DCHECK(channel_ != NULL); 128 DCHECK(channel_.get() != NULL);
129 channel_->Send(new PluginMsg_WillSendRequest(instance_id_, resource_id_, 129 channel_->Send(new PluginMsg_WillSendRequest(
130 url, http_status_code)); 130 instance_id_, resource_id_, url, http_status_code));
131 } 131 }
132 132
133 virtual void DidReceiveResponse(const std::string& mime_type, 133 virtual void DidReceiveResponse(const std::string& mime_type,
134 const std::string& headers, 134 const std::string& headers,
135 uint32 expected_length, 135 uint32 expected_length,
136 uint32 last_modified, 136 uint32 last_modified,
137 bool request_is_seekable) OVERRIDE { 137 bool request_is_seekable) OVERRIDE {
138 DCHECK(channel_ != NULL); 138 DCHECK(channel_.get() != NULL);
139 PluginMsg_DidReceiveResponseParams params; 139 PluginMsg_DidReceiveResponseParams params;
140 params.id = resource_id_; 140 params.id = resource_id_;
141 params.mime_type = mime_type; 141 params.mime_type = mime_type;
142 params.headers = headers; 142 params.headers = headers;
143 params.expected_length = expected_length; 143 params.expected_length = expected_length;
144 params.last_modified = last_modified; 144 params.last_modified = last_modified;
145 params.request_is_seekable = request_is_seekable; 145 params.request_is_seekable = request_is_seekable;
146 // Grab a reference on the underlying channel so it does not get 146 // Grab a reference on the underlying channel so it does not get
147 // deleted from under us. 147 // deleted from under us.
148 scoped_refptr<PluginChannelHost> channel_ref(channel_); 148 scoped_refptr<PluginChannelHost> channel_ref(channel_);
149 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params)); 149 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params));
150 } 150 }
151 151
152 virtual void DidReceiveData(const char* buffer, 152 virtual void DidReceiveData(const char* buffer,
153 int length, 153 int length,
154 int data_offset) OVERRIDE { 154 int data_offset) OVERRIDE {
155 DCHECK(channel_ != NULL); 155 DCHECK(channel_.get() != NULL);
156 DCHECK_GT(length, 0); 156 DCHECK_GT(length, 0);
157 std::vector<char> data; 157 std::vector<char> data;
158 data.resize(static_cast<size_t>(length)); 158 data.resize(static_cast<size_t>(length));
159 memcpy(&data.front(), buffer, length); 159 memcpy(&data.front(), buffer, length);
160 // Grab a reference on the underlying channel so it does not get 160 // Grab a reference on the underlying channel so it does not get
161 // deleted from under us. 161 // deleted from under us.
162 scoped_refptr<PluginChannelHost> channel_ref(channel_); 162 scoped_refptr<PluginChannelHost> channel_ref(channel_);
163 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_, 163 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_,
164 data, data_offset)); 164 data, data_offset));
165 } 165 }
166 166
167 virtual void DidFinishLoading() OVERRIDE { 167 virtual void DidFinishLoading() OVERRIDE {
168 DCHECK(channel_ != NULL); 168 DCHECK(channel_.get() != NULL);
169 channel_->Send(new PluginMsg_DidFinishLoading(instance_id_, resource_id_)); 169 channel_->Send(new PluginMsg_DidFinishLoading(instance_id_, resource_id_));
170 channel_ = NULL; 170 channel_ = NULL;
171 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 171 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
172 } 172 }
173 173
174 virtual void DidFail() OVERRIDE { 174 virtual void DidFail() OVERRIDE {
175 DCHECK(channel_ != NULL); 175 DCHECK(channel_.get() != NULL);
176 channel_->Send(new PluginMsg_DidFail(instance_id_, resource_id_)); 176 channel_->Send(new PluginMsg_DidFail(instance_id_, resource_id_));
177 channel_ = NULL; 177 channel_ = NULL;
178 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 178 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
179 } 179 }
180 180
181 virtual bool IsMultiByteResponseExpected() OVERRIDE { 181 virtual bool IsMultiByteResponseExpected() OVERRIDE {
182 return multibyte_response_expected_; 182 return multibyte_response_expected_;
183 } 183 }
184 184
185 virtual int ResourceId() OVERRIDE { 185 virtual int ResourceId() OVERRIDE {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 243 }
244 dummy_activation_window_ = NULL; 244 dummy_activation_window_ = NULL;
245 #endif 245 #endif
246 246
247 if (window_) 247 if (window_)
248 WillDestroyWindow(); 248 WillDestroyWindow();
249 249
250 if (render_view_) 250 if (render_view_)
251 render_view_->UnregisterPluginDelegate(this); 251 render_view_->UnregisterPluginDelegate(this);
252 252
253 if (channel_host_) { 253 if (channel_host_.get()) {
254 Send(new PluginMsg_DestroyInstance(instance_id_)); 254 Send(new PluginMsg_DestroyInstance(instance_id_));
255 255
256 // Must remove the route after sending the destroy message, since 256 // Must remove the route after sending the destroy message, since
257 // RemoveRoute can lead to all the outstanding NPObjects being told the 257 // RemoveRoute can lead to all the outstanding NPObjects being told the
258 // channel went away if this was the last instance. 258 // channel went away if this was the last instance.
259 channel_host_->RemoveRoute(instance_id_); 259 channel_host_->RemoveRoute(instance_id_);
260 260
261 // Release the channel host now. If we are is the last reference to the 261 // Release the channel host now. If we are is the last reference to the
262 // channel, this avoids a race where this renderer asks a new connection to 262 // channel, this avoids a race where this renderer asks a new connection to
263 // the same plugin between now and the time 'this' is actually deleted. 263 // the same plugin between now and the time 'this' is actually deleted.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // crashed plugin there. 327 // crashed plugin there.
328 return true; 328 return true;
329 } 329 }
330 LOG(ERROR) << "Plug-in couldn't be found"; 330 LOG(ERROR) << "Plug-in couldn't be found";
331 return false; 331 return false;
332 } 332 }
333 333
334 channel_host = 334 channel_host =
335 PluginChannelHost::GetPluginChannelHost( 335 PluginChannelHost::GetPluginChannelHost(
336 channel_handle, ChildProcess::current()->io_message_loop_proxy()); 336 channel_handle, ChildProcess::current()->io_message_loop_proxy());
337 if (!channel_host) { 337 if (!channel_host.get()) {
338 LOG(ERROR) << "Couldn't get PluginChannelHost"; 338 LOG(ERROR) << "Couldn't get PluginChannelHost";
339 continue; 339 continue;
340 } 340 }
341 #if defined(OS_MACOSX) 341 #if defined(OS_MACOSX)
342 track_nested_removes.reset(); 342 track_nested_removes.reset();
343 #endif 343 #endif
344 344
345 { 345 {
346 // TODO(bauerb): Debugging for http://crbug.com/141055. 346 // TODO(bauerb): Debugging for http://crbug.com/141055.
347 ScopedLogLevel log_level(-2); // Equivalent to --v=2 347 ScopedLogLevel log_level(-2); // Equivalent to --v=2
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 379
380 if (!result) 380 if (!result)
381 LOG(ERROR) << "PluginMsg_Init returned false"; 381 LOG(ERROR) << "PluginMsg_Init returned false";
382 382
383 render_view_->RegisterPluginDelegate(this); 383 render_view_->RegisterPluginDelegate(this);
384 384
385 return result; 385 return result;
386 } 386 }
387 387
388 bool WebPluginDelegateProxy::Send(IPC::Message* msg) { 388 bool WebPluginDelegateProxy::Send(IPC::Message* msg) {
389 if (!channel_host_) { 389 if (!channel_host_.get()) {
390 DLOG(WARNING) << "dropping message because channel host is null"; 390 DLOG(WARNING) << "dropping message because channel host is null";
391 delete msg; 391 delete msg;
392 return false; 392 return false;
393 } 393 }
394 394
395 return channel_host_->Send(msg); 395 return channel_host_->Send(msg);
396 } 396 }
397 397
398 void WebPluginDelegateProxy::SendJavaScriptStream(const GURL& url, 398 void WebPluginDelegateProxy::SendJavaScriptStream(const GURL& url,
399 const std::string& result, 399 const std::string& result,
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 #endif 673 #endif
674 674
675 void WebPluginDelegateProxy::Paint(WebKit::WebCanvas* canvas, 675 void WebPluginDelegateProxy::Paint(WebKit::WebCanvas* canvas,
676 const gfx::Rect& damaged_rect) { 676 const gfx::Rect& damaged_rect) {
677 // Limit the damaged rectangle to whatever is contained inside the plugin 677 // Limit the damaged rectangle to whatever is contained inside the plugin
678 // rectangle, as that's the rectangle that we'll actually draw. 678 // rectangle, as that's the rectangle that we'll actually draw.
679 gfx::Rect rect = gfx::IntersectRects(damaged_rect, plugin_rect_); 679 gfx::Rect rect = gfx::IntersectRects(damaged_rect, plugin_rect_);
680 680
681 // If the plugin is no longer connected (channel crashed) draw a crashed 681 // If the plugin is no longer connected (channel crashed) draw a crashed
682 // plugin bitmap 682 // plugin bitmap
683 if (!channel_host_ || !channel_host_->channel_valid()) { 683 if (!channel_host_.get() || !channel_host_->channel_valid()) {
684 PaintSadPlugin(canvas, rect); 684 PaintSadPlugin(canvas, rect);
685 return; 685 return;
686 } 686 }
687 687
688 if (!uses_shared_bitmaps_) 688 if (!uses_shared_bitmaps_)
689 return; 689 return;
690 690
691 // We got a paint before the plugin's coordinates, so there's no buffer to 691 // We got a paint before the plugin's coordinates, so there's no buffer to
692 // copy from. 692 // copy from.
693 if (!front_buffer_canvas()) 693 if (!front_buffer_canvas())
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 1099
1100 plugin_->HandleURLRequest( 1100 plugin_->HandleURLRequest(
1101 params.url.c_str(), params.method.c_str(), target, data, 1101 params.url.c_str(), params.method.c_str(), target, data,
1102 static_cast<unsigned int>(params.buffer.size()), params.notify_id, 1102 static_cast<unsigned int>(params.buffer.size()), params.notify_id,
1103 params.popups_allowed, params.notify_redirects); 1103 params.popups_allowed, params.notify_redirects);
1104 } 1104 }
1105 1105
1106 webkit::npapi::WebPluginResourceClient* 1106 webkit::npapi::WebPluginResourceClient*
1107 WebPluginDelegateProxy::CreateResourceClient( 1107 WebPluginDelegateProxy::CreateResourceClient(
1108 unsigned long resource_id, const GURL& url, int notify_id) { 1108 unsigned long resource_id, const GURL& url, int notify_id) {
1109 if (!channel_host_) 1109 if (!channel_host_.get())
1110 return NULL; 1110 return NULL;
1111 1111
1112 ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, 1112 ResourceClientProxy* proxy =
1113 instance_id_); 1113 new ResourceClientProxy(channel_host_.get(), instance_id_);
1114 proxy->Initialize(resource_id, url, notify_id); 1114 proxy->Initialize(resource_id, url, notify_id);
1115 return proxy; 1115 return proxy;
1116 } 1116 }
1117 1117
1118 webkit::npapi::WebPluginResourceClient* 1118 webkit::npapi::WebPluginResourceClient*
1119 WebPluginDelegateProxy::CreateSeekableResourceClient( 1119 WebPluginDelegateProxy::CreateSeekableResourceClient(
1120 unsigned long resource_id, int range_request_id) { 1120 unsigned long resource_id, int range_request_id) {
1121 if (!channel_host_) 1121 if (!channel_host_.get())
1122 return NULL; 1122 return NULL;
1123 1123
1124 ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, 1124 ResourceClientProxy* proxy =
1125 instance_id_); 1125 new ResourceClientProxy(channel_host_.get(), instance_id_);
1126 proxy->InitializeForSeekableStream(resource_id, range_request_id); 1126 proxy->InitializeForSeekableStream(resource_id, range_request_id);
1127 return proxy; 1127 return proxy;
1128 } 1128 }
1129 1129
1130 #if defined(OS_MACOSX) 1130 #if defined(OS_MACOSX)
1131 void WebPluginDelegateProxy::OnFocusChanged(bool focused) { 1131 void WebPluginDelegateProxy::OnFocusChanged(bool focused) {
1132 if (render_view_) 1132 if (render_view_)
1133 render_view_->PluginFocusChanged(focused, instance_id_); 1133 render_view_->PluginFocusChanged(focused, instance_id_);
1134 } 1134 }
1135 1135
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 1206
1207 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, 1207 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow,
1208 int resource_id) { 1208 int resource_id) {
1209 if (!plugin_) 1209 if (!plugin_)
1210 return; 1210 return;
1211 1211
1212 plugin_->URLRedirectResponse(allow, resource_id); 1212 plugin_->URLRedirectResponse(allow, resource_id);
1213 } 1213 }
1214 1214
1215 } // namespace content 1215 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/skia_benchmarking_extension.cc ('k') | content/shell/shell_browser_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698