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

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

Issue 8965053: Implement support for a cancelable SyncSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Using a single event for file operations on Windows. Some comment improvements. Created 8 years, 12 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) 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 "content/renderer/pepper_plugin_delegate_impl.h" 5 #include "content/renderer/pepper_plugin_delegate_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 } 815 }
816 } 816 }
817 pending_connects_.clear(); 817 pending_connects_.clear();
818 } 818 }
819 819
820 void PpapiBrokerImpl::ConnectPluginToBroker( 820 void PpapiBrokerImpl::ConnectPluginToBroker(
821 webkit::ppapi::PPB_Broker_Impl* client) { 821 webkit::ppapi::PPB_Broker_Impl* client) {
822 base::SyncSocket::Handle plugin_handle = base::kInvalidPlatformFileValue; 822 base::SyncSocket::Handle plugin_handle = base::kInvalidPlatformFileValue;
823 int32_t result = PP_OK; 823 int32_t result = PP_OK;
824 824
825 base::SyncSocket* sockets[2] = {0}; 825 // The socket objects will be deleted when this function exits, closing the
826 if (base::SyncSocket::CreatePair(sockets)) { 826 // handles. Any uses of the socket must duplicate them.
827 // The socket objects will be deleted when this function exits, closing the 827 scoped_ptr<base::SyncSocket> broker_socket(new base::SyncSocket());
828 // handles. Any uses of the socket must duplicate them. 828 scoped_ptr<base::SyncSocket> plugin_socket(new base::SyncSocket());
829 scoped_ptr<base::SyncSocket> broker_socket(sockets[0]); 829 if (base::SyncSocket::CreatePair(broker_socket.get(), plugin_socket.get())) {
830 scoped_ptr<base::SyncSocket> plugin_socket(sockets[1]);
831
832 result = dispatcher_->SendHandleToBroker(client->pp_instance(), 830 result = dispatcher_->SendHandleToBroker(client->pp_instance(),
833 broker_socket->handle()); 831 broker_socket->handle());
834 832
835 // If the broker has its pipe handle, duplicate the plugin's handle. 833 // If the broker has its pipe handle, duplicate the plugin's handle.
836 // Otherwise, the plugin's handle will be automatically closed. 834 // Otherwise, the plugin's handle will be automatically closed.
837 if (result == PP_OK) 835 if (result == PP_OK)
838 plugin_handle = DuplicateHandle(plugin_socket->handle()); 836 plugin_handle = DuplicateHandle(plugin_socket->handle());
839 } else { 837 } else {
840 result = PP_ERROR_FAILED; 838 result = PP_ERROR_FAILED;
841 } 839 }
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 2145
2148 bool PepperPluginDelegateImpl::CanUseSocketAPIs() { 2146 bool PepperPluginDelegateImpl::CanUseSocketAPIs() {
2149 WebView* webview = render_view_->webview(); 2147 WebView* webview = render_view_->webview();
2150 WebFrame* main_frame = webview ? webview->mainFrame() : NULL; 2148 WebFrame* main_frame = webview ? webview->mainFrame() : NULL;
2151 GURL url(main_frame ? GURL(main_frame->document().url()) : GURL()); 2149 GURL url(main_frame ? GURL(main_frame->document().url()) : GURL());
2152 if (!url.is_valid()) 2150 if (!url.is_valid())
2153 return false; 2151 return false;
2154 2152
2155 return content::GetContentClient()->renderer()->AllowSocketAPI(url); 2153 return content::GetContentClient()->renderer()->AllowSocketAPI(url);
2156 } 2154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698