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

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

Issue 9958034: Convert plugin and GPU process to brokered handle duplication. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
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>
11 #endif 11 #endif
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/file_util.h" 17 #include "base/file_util.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/process.h"
21 #include "base/string_split.h" 22 #include "base/string_split.h"
22 #include "base/string_util.h" 23 #include "base/string_util.h"
23 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
24 #include "base/version.h" 25 #include "base/version.h"
25 #include "content/common/child_process.h" 26 #include "content/common/child_process.h"
26 #include "content/common/npobject_proxy.h" 27 #include "content/common/npobject_proxy.h"
27 #include "content/common/npobject_stub.h" 28 #include "content/common/npobject_stub.h"
28 #include "content/common/npobject_util.h" 29 #include "content/common/npobject_util.h"
29 #include "content/common/plugin_messages.h" 30 #include "content/common/plugin_messages.h"
30 #include "content/common/view_messages.h" 31 #include "content/common/view_messages.h"
(...skipping 21 matching lines...) Expand all
52 #include "webkit/plugins/sad_plugin.h" 53 #include "webkit/plugins/sad_plugin.h"
53 54
54 #if defined(OS_POSIX) 55 #if defined(OS_POSIX)
55 #include "ipc/ipc_channel_posix.h" 56 #include "ipc/ipc_channel_posix.h"
56 #endif 57 #endif
57 58
58 #if defined(OS_MACOSX) 59 #if defined(OS_MACOSX)
59 #include "base/mac/mac_util.h" 60 #include "base/mac/mac_util.h"
60 #endif 61 #endif
61 62
63 #if defined(OS_WIN)
64 #include "content/common/sandbox_policy.h"
65 #endif
66
62 using WebKit::WebBindings; 67 using WebKit::WebBindings;
63 using WebKit::WebCursorInfo; 68 using WebKit::WebCursorInfo;
64 using WebKit::WebDragData; 69 using WebKit::WebDragData;
65 using WebKit::WebInputEvent; 70 using WebKit::WebInputEvent;
66 using WebKit::WebString; 71 using WebKit::WebString;
67 using WebKit::WebView; 72 using WebKit::WebView;
68 73
69 // Proxy for WebPluginResourceClient. The object owns itself after creation, 74 // Proxy for WebPluginResourceClient. The object owns itself after creation,
70 // deleting itself after its callback has been called. 75 // deleting itself after its callback has been called.
71 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { 76 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient {
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 481
477 #if defined(OS_MACOSX) || defined(OS_WIN) 482 #if defined(OS_MACOSX) || defined(OS_WIN)
478 // Ensure that the renderer doesn't think the plugin still has focus. 483 // Ensure that the renderer doesn't think the plugin still has focus.
479 if (render_view_) 484 if (render_view_)
480 render_view_->PluginFocusChanged(false, instance_id_); 485 render_view_->PluginFocusChanged(false, instance_id_);
481 #endif 486 #endif
482 } 487 }
483 488
484 static void CopyTransportDIBHandleForMessage( 489 static void CopyTransportDIBHandleForMessage(
485 const TransportDIB::Handle& handle_in, 490 const TransportDIB::Handle& handle_in,
486 TransportDIB::Handle* handle_out) { 491 TransportDIB::Handle* handle_out,
492 base::ProcessId peer_pid) {
487 #if defined(OS_MACOSX) 493 #if defined(OS_MACOSX)
488 // On Mac, TransportDIB::Handle is typedef'ed to FileDescriptor, and 494 // On Mac, TransportDIB::Handle is typedef'ed to FileDescriptor, and
489 // FileDescriptor message fields needs to remain valid until the message is 495 // FileDescriptor message fields needs to remain valid until the message is
490 // sent or else the sendmsg() call will fail. 496 // sent or else the sendmsg() call will fail.
491 if ((handle_out->fd = HANDLE_EINTR(dup(handle_in.fd))) < 0) { 497 if ((handle_out->fd = HANDLE_EINTR(dup(handle_in.fd))) < 0) {
492 PLOG(ERROR) << "dup()"; 498 PLOG(ERROR) << "dup()";
493 return; 499 return;
494 } 500 }
495 handle_out->auto_close = true; 501 handle_out->auto_close = true;
502 #elif defined(OS_WIN)
503 // On Windows we need to duplicate the handle for the plugin process.
504 *handle_out = NULL;
505 sandbox::BrokerDuplicateHandle(handle_in, peer_pid, handle_out,
506 FILE_MAP_READ | FILE_MAP_WRITE, 0);
507 CHECK(*handle_out != NULL);
496 #else 508 #else
497 // Don't need to do anything special for other platforms. 509 // Don't need to do anything special for other platforms.
498 *handle_out = handle_in; 510 *handle_out = handle_in;
499 #endif 511 #endif
500 } 512 }
501 513
502 void WebPluginDelegateProxy::SendUpdateGeometry( 514 void WebPluginDelegateProxy::SendUpdateGeometry(
503 bool bitmaps_changed) { 515 bool bitmaps_changed) {
504 PluginMsg_UpdateGeometry_Param param; 516 PluginMsg_UpdateGeometry_Param param;
505 param.window_rect = plugin_rect_; 517 param.window_rect = plugin_rect_;
506 param.clip_rect = clip_rect_; 518 param.clip_rect = clip_rect_;
507 param.windowless_buffer0 = TransportDIB::DefaultHandleValue(); 519 param.windowless_buffer0 = TransportDIB::DefaultHandleValue();
508 param.windowless_buffer1 = TransportDIB::DefaultHandleValue(); 520 param.windowless_buffer1 = TransportDIB::DefaultHandleValue();
509 param.windowless_buffer_index = back_buffer_index(); 521 param.windowless_buffer_index = back_buffer_index();
510 param.background_buffer = TransportDIB::DefaultHandleValue(); 522 param.background_buffer = TransportDIB::DefaultHandleValue();
511 param.transparent = transparent_; 523 param.transparent = transparent_;
512 524
513 #if defined(OS_POSIX) 525 #if defined(OS_POSIX)
514 // If we're using POSIX mmap'd TransportDIBs, sending the handle across 526 // If we're using POSIX mmap'd TransportDIBs, sending the handle across
515 // IPC establishes a new mapping rather than just sending a window ID, 527 // IPC establishes a new mapping rather than just sending a window ID,
516 // so only do so if we've actually changed the shared memory bitmaps. 528 // so only do so if we've actually changed the shared memory bitmaps.
517 if (bitmaps_changed) 529 if (bitmaps_changed)
518 #endif 530 #endif
519 { 531 {
520 if (transport_stores_[0].dib.get()) 532 if (transport_stores_[0].dib.get())
521 CopyTransportDIBHandleForMessage(transport_stores_[0].dib->handle(), 533 CopyTransportDIBHandleForMessage(transport_stores_[0].dib->handle(),
522 &param.windowless_buffer0); 534 &param.windowless_buffer0,
535 channel_host_->peer_pid());
523 536
524 if (transport_stores_[1].dib.get()) 537 if (transport_stores_[1].dib.get())
525 CopyTransportDIBHandleForMessage(transport_stores_[1].dib->handle(), 538 CopyTransportDIBHandleForMessage(transport_stores_[1].dib->handle(),
526 &param.windowless_buffer1); 539 &param.windowless_buffer1,
540 channel_host_->peer_pid());
527 541
528 if (background_store_.dib.get()) 542 if (background_store_.dib.get())
529 CopyTransportDIBHandleForMessage(background_store_.dib->handle(), 543 CopyTransportDIBHandleForMessage(background_store_.dib->handle(),
530 &param.background_buffer); 544 &param.background_buffer,
545 channel_host_->peer_pid());
531 } 546 }
532 547
533 IPC::Message* msg; 548 IPC::Message* msg;
534 #if defined(OS_WIN) 549 #if defined(OS_WIN)
535 if (UseSynchronousGeometryUpdates()) { 550 if (UseSynchronousGeometryUpdates()) {
536 msg = new PluginMsg_UpdateGeometrySync(instance_id_, param); 551 msg = new PluginMsg_UpdateGeometrySync(instance_id_, param);
537 } else // NOLINT 552 } else // NOLINT
538 #endif 553 #endif
539 { 554 {
540 msg = new PluginMsg_UpdateGeometry(instance_id_, param); 555 msg = new PluginMsg_UpdateGeometry(instance_id_, param);
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 } 1471 }
1457 #endif 1472 #endif
1458 1473
1459 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, 1474 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow,
1460 int resource_id) { 1475 int resource_id) {
1461 if (!plugin_) 1476 if (!plugin_)
1462 return; 1477 return;
1463 1478
1464 plugin_->URLRedirectResponse(allow, resource_id); 1479 plugin_->URLRedirectResponse(allow, resource_id);
1465 } 1480 }
OLDNEW
« content/common/sandbox_policy.cc ('K') | « content/renderer/render_thread_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698