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

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

Issue 8342016: Revert 106142 - Add a new globals object for PPAPI tracking information. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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/plugin_object.cc ('k') | webkit/plugins/ppapi/ppb_audio_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/src/webkit/plugins/ppapi/ppapi_plugin_instance.cc:r3734-4217,4606-5108,5177-5263
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/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
59 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 59 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
60 #include "ui/gfx/rect.h" 60 #include "ui/gfx/rect.h"
61 #include "ui/gfx/skia_util.h" 61 #include "ui/gfx/skia_util.h"
62 #include "webkit/plugins/ppapi/common.h" 62 #include "webkit/plugins/ppapi/common.h"
63 #include "webkit/plugins/ppapi/event_conversion.h" 63 #include "webkit/plugins/ppapi/event_conversion.h"
64 #include "webkit/plugins/ppapi/fullscreen_container.h" 64 #include "webkit/plugins/ppapi/fullscreen_container.h"
65 #include "webkit/plugins/ppapi/host_globals.h"
66 #include "webkit/plugins/ppapi/message_channel.h" 65 #include "webkit/plugins/ppapi/message_channel.h"
67 #include "webkit/plugins/ppapi/npapi_glue.h" 66 #include "webkit/plugins/ppapi/npapi_glue.h"
68 #include "webkit/plugins/ppapi/plugin_delegate.h" 67 #include "webkit/plugins/ppapi/plugin_delegate.h"
69 #include "webkit/plugins/ppapi/plugin_module.h" 68 #include "webkit/plugins/ppapi/plugin_module.h"
70 #include "webkit/plugins/ppapi/plugin_object.h" 69 #include "webkit/plugins/ppapi/plugin_object.h"
71 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 70 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
72 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" 71 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
73 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" 72 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
74 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 73 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
75 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" 74 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
(...skipping 20 matching lines...) Expand all
96 #include "ui/gfx/codec/jpeg_codec.h" 95 #include "ui/gfx/codec/jpeg_codec.h"
97 #include "ui/gfx/gdi_util.h" 96 #include "ui/gfx/gdi_util.h"
98 #endif 97 #endif
99 98
100 #if defined(OS_MACOSX) && defined(USE_SKIA) 99 #if defined(OS_MACOSX) && defined(USE_SKIA)
101 #include "skia/ext/skia_utils_mac.h" 100 #include "skia/ext/skia_utils_mac.h"
102 #endif 101 #endif
103 102
104 using base::StringPrintf; 103 using base::StringPrintf;
105 using ppapi::InputEventImpl; 104 using ppapi::InputEventImpl;
106 using ppapi::PpapiGlobals;
107 using ppapi::StringVar; 105 using ppapi::StringVar;
108 using ppapi::thunk::EnterResourceNoLock; 106 using ppapi::thunk::EnterResourceNoLock;
109 using ppapi::thunk::PPB_Buffer_API; 107 using ppapi::thunk::PPB_Buffer_API;
110 using ppapi::thunk::PPB_Graphics2D_API; 108 using ppapi::thunk::PPB_Graphics2D_API;
111 using ppapi::thunk::PPB_Graphics3D_API; 109 using ppapi::thunk::PPB_Graphics3D_API;
112 using ppapi::thunk::PPB_ImageData_API; 110 using ppapi::thunk::PPB_ImageData_API;
113 using ppapi::thunk::PPB_Instance_FunctionAPI; 111 using ppapi::thunk::PPB_Instance_FunctionAPI;
114 using ppapi::thunk::PPB_Surface3D_API; 112 using ppapi::thunk::PPB_Surface3D_API;
115 using ppapi::Var; 113 using ppapi::Var;
116 using WebKit::WebBindings; 114 using WebKit::WebBindings;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 *output = PP_MakeRectFromXYWH(input.x(), input.y(), 235 *output = PP_MakeRectFromXYWH(input.x(), input.y(),
238 input.width(), input.height()); 236 input.width(), input.height());
239 } 237 }
240 238
241 // Sets |*security_origin| to be the WebKit security origin associated with the 239 // Sets |*security_origin| to be the WebKit security origin associated with the
242 // document containing the given plugin instance. On success, returns true. If 240 // document containing the given plugin instance. On success, returns true. If
243 // the instance is invalid, returns false and |*security_origin| will be 241 // the instance is invalid, returns false and |*security_origin| will be
244 // unchanged. 242 // unchanged.
245 bool SecurityOriginForInstance(PP_Instance instance_id, 243 bool SecurityOriginForInstance(PP_Instance instance_id,
246 WebKit::WebSecurityOrigin* security_origin) { 244 WebKit::WebSecurityOrigin* security_origin) {
247 PluginInstance* instance = 245 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
248 HostGlobals::Get()->host_resource_tracker()->GetInstance(instance_id);
249 if (!instance) 246 if (!instance)
250 return false; 247 return false;
251 248
252 WebElement plugin_element = instance->container()->element(); 249 WebElement plugin_element = instance->container()->element();
253 *security_origin = plugin_element.document().securityOrigin(); 250 *security_origin = plugin_element.document().securityOrigin();
254 return true; 251 return true;
255 } 252 }
256 253
257 } // namespace 254 } // namespace
258 255
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 fullscreen_(false), 299 fullscreen_(false),
303 message_channel_(NULL), 300 message_channel_(NULL),
304 sad_plugin_(NULL), 301 sad_plugin_(NULL),
305 input_event_mask_(0), 302 input_event_mask_(0),
306 filtered_input_event_mask_(0), 303 filtered_input_event_mask_(0),
307 text_input_type_(kPluginDefaultTextInputType), 304 text_input_type_(kPluginDefaultTextInputType),
308 text_input_caret_(0, 0, 0, 0), 305 text_input_caret_(0, 0, 0, 0),
309 text_input_caret_bounds_(0, 0, 0, 0), 306 text_input_caret_bounds_(0, 0, 0, 0),
310 text_input_caret_set_(false), 307 text_input_caret_set_(false),
311 lock_mouse_callback_(PP_BlockUntilComplete()) { 308 lock_mouse_callback_(PP_BlockUntilComplete()) {
312 pp_instance_ = HostGlobals::Get()->host_resource_tracker()->AddInstance(this); 309 pp_instance_ = ResourceTracker::Get()->AddInstance(this);
313 310
314 memset(&current_print_settings_, 0, sizeof(current_print_settings_)); 311 memset(&current_print_settings_, 0, sizeof(current_print_settings_));
315 DCHECK(delegate); 312 DCHECK(delegate);
316 module_->InstanceCreated(this); 313 module_->InstanceCreated(this);
317 delegate_->InstanceCreated(this); 314 delegate_->InstanceCreated(this);
318 message_channel_.reset(new MessageChannel(this)); 315 message_channel_.reset(new MessageChannel(this));
319 } 316 }
320 317
321 PluginInstance::~PluginInstance() { 318 PluginInstance::~PluginInstance() {
322 DCHECK(!fullscreen_container_); 319 DCHECK(!fullscreen_container_);
323 320
324 // Free all the plugin objects. This will automatically clear the back- 321 // Free all the plugin objects. This will automatically clear the back-
325 // pointer from the NPObject so WebKit can't call into the plugin any more. 322 // pointer from the NPObject so WebKit can't call into the plugin any more.
326 // 323 //
327 // Swap out the set so we can delete from it (the objects will try to 324 // Swap out the set so we can delete from it (the objects will try to
328 // unregister themselves inside the delete call). 325 // unregister themselves inside the delete call).
329 PluginObjectSet plugin_object_copy; 326 PluginObjectSet plugin_object_copy;
330 live_plugin_objects_.swap(plugin_object_copy); 327 live_plugin_objects_.swap(plugin_object_copy);
331 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); 328 for (PluginObjectSet::iterator i = plugin_object_copy.begin();
332 i != plugin_object_copy.end(); ++i) 329 i != plugin_object_copy.end(); ++i)
333 delete *i; 330 delete *i;
334 331
335 if (lock_mouse_callback_.func) 332 if (lock_mouse_callback_.func)
336 PP_RunAndClearCompletionCallback(&lock_mouse_callback_, PP_ERROR_ABORTED); 333 PP_RunAndClearCompletionCallback(&lock_mouse_callback_, PP_ERROR_ABORTED);
337 334
338 delegate_->InstanceDeleted(this); 335 delegate_->InstanceDeleted(this);
339 module_->InstanceDeleted(this); 336 module_->InstanceDeleted(this);
340 337
341 HostGlobals::Get()->host_resource_tracker()->InstanceDeleted(pp_instance_); 338 ResourceTracker::Get()->InstanceDeleted(pp_instance_);
342 } 339 }
343 340
344 // NOTE: Any of these methods that calls into the plugin needs to take into 341 // NOTE: Any of these methods that calls into the plugin needs to take into
345 // account that the plugin may use Var to remove the <embed> from the DOM, which 342 // account that the plugin may use Var to remove the <embed> from the DOM, which
346 // will make the WebPluginImpl drop its reference, usually the last one. If a 343 // will make the WebPluginImpl drop its reference, usually the last one. If a
347 // method needs to access a member of the instance after the call has returned, 344 // method needs to access a member of the instance after the call has returned,
348 // then it needs to keep its own reference on the stack. 345 // then it needs to keep its own reference on the stack.
349 346
350 void PluginInstance::Delete() { 347 void PluginInstance::Delete() {
351 // Keep a reference on the stack. See NOTE above. 348 // Keep a reference on the stack. See NOTE above.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 416
420 void PluginInstance::CommitBackingTexture() { 417 void PluginInstance::CommitBackingTexture() {
421 if (fullscreen_container_) 418 if (fullscreen_container_)
422 fullscreen_container_->Invalidate(); 419 fullscreen_container_->Invalidate();
423 else if (container_) 420 else if (container_)
424 container_->commitBackingTexture(); 421 container_->commitBackingTexture();
425 } 422 }
426 423
427 void PluginInstance::InstanceCrashed() { 424 void PluginInstance::InstanceCrashed() {
428 // Force free all resources and vars. 425 // Force free all resources and vars.
429 HostGlobals::Get()->host_resource_tracker()->InstanceCrashed(pp_instance()); 426 ResourceTracker::Get()->InstanceCrashed(pp_instance());
430 427
431 // Free any associated graphics. 428 // Free any associated graphics.
432 SetFullscreen(false, false); 429 SetFullscreen(false, false);
433 FlashSetFullscreen(false, false); 430 FlashSetFullscreen(false, false);
434 bound_graphics_ = NULL; 431 bound_graphics_ = NULL;
435 InvalidateRect(gfx::Rect()); 432 InvalidateRect(gfx::Rect());
436 433
437 delegate()->PluginCrashed(this); 434 delegate()->PluginCrashed(this);
438 } 435 }
439 436
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 if (!LoadSelectionInterface()) 863 if (!LoadSelectionInterface())
867 return string16(); 864 return string16();
868 865
869 PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(), 866 PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(),
870 PP_FromBool(html)); 867 PP_FromBool(html));
871 StringVar* string = StringVar::FromPPVar(rv); 868 StringVar* string = StringVar::FromPPVar(rv);
872 string16 selection; 869 string16 selection;
873 if (string) 870 if (string)
874 selection = UTF8ToUTF16(string->value()); 871 selection = UTF8ToUTF16(string->value());
875 // Release the ref the plugin transfered to us. 872 // Release the ref the plugin transfered to us.
876 HostGlobals::Get()->GetVarTracker()->ReleaseVar(rv); 873 ResourceTracker::Get()->GetVarTracker()->ReleaseVar(rv);
877 return selection; 874 return selection;
878 } 875 }
879 876
880 string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) { 877 string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) {
881 // Keep a reference on the stack. See NOTE above. 878 // Keep a reference on the stack. See NOTE above.
882 scoped_refptr<PluginInstance> ref(this); 879 scoped_refptr<PluginInstance> ref(this);
883 if (!LoadPdfInterface()) 880 if (!LoadPdfInterface())
884 return string16(); 881 return string16();
885 882
886 PP_Point p; 883 PP_Point p;
887 p.x = point.x(); 884 p.x = point.x();
888 p.y = point.y(); 885 p.y = point.y();
889 PP_Var rv = plugin_pdf_interface_->GetLinkAtPosition(pp_instance(), p); 886 PP_Var rv = plugin_pdf_interface_->GetLinkAtPosition(pp_instance(), p);
890 StringVar* string = StringVar::FromPPVar(rv); 887 StringVar* string = StringVar::FromPPVar(rv);
891 string16 link; 888 string16 link;
892 if (string) 889 if (string)
893 link = UTF8ToUTF16(string->value()); 890 link = UTF8ToUTF16(string->value());
894 // Release the ref the plugin transfered to us. 891 // Release the ref the plugin transfered to us.
895 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(rv); 892 ResourceTracker::Get()->GetVarTracker()->ReleaseVar(rv);
896 return link; 893 return link;
897 } 894 }
898 895
899 void PluginInstance::Zoom(double factor, bool text_only) { 896 void PluginInstance::Zoom(double factor, bool text_only) {
900 // Keep a reference on the stack. See NOTE above. 897 // Keep a reference on the stack. See NOTE above.
901 scoped_refptr<PluginInstance> ref(this); 898 scoped_refptr<PluginInstance> ref(this);
902 if (!LoadZoomInterface()) 899 if (!LoadZoomInterface())
903 return; 900 return;
904 plugin_zoom_interface_->Zoom(pp_instance(), factor, PP_FromBool(text_only)); 901 plugin_zoom_interface_->Zoom(pp_instance(), factor, PP_FromBool(text_only));
905 } 902 }
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 screen_size_for_fullscreen_ = gfx::Size(); 2064 screen_size_for_fullscreen_ = gfx::Size();
2068 WebElement element = container_->element(); 2065 WebElement element = container_->element();
2069 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2066 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2070 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2067 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2071 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2068 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2072 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2069 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2073 } 2070 }
2074 2071
2075 } // namespace ppapi 2072 } // namespace ppapi
2076 } // namespace webkit 2073 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/plugin_object.cc ('k') | webkit/plugins/ppapi/ppb_audio_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698