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

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: addressed micro-nit Created 8 years, 11 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/browser/renderer_host/media/audio_sync_reader.cc ('k') | ipc/sync_socket_unittest.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/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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 } 813 }
814 } 814 }
815 pending_connects_.clear(); 815 pending_connects_.clear();
816 } 816 }
817 817
818 void PpapiBrokerImpl::ConnectPluginToBroker( 818 void PpapiBrokerImpl::ConnectPluginToBroker(
819 webkit::ppapi::PPB_Broker_Impl* client) { 819 webkit::ppapi::PPB_Broker_Impl* client) {
820 base::SyncSocket::Handle plugin_handle = base::kInvalidPlatformFileValue; 820 base::SyncSocket::Handle plugin_handle = base::kInvalidPlatformFileValue;
821 int32_t result = PP_OK; 821 int32_t result = PP_OK;
822 822
823 base::SyncSocket* sockets[2] = {0}; 823 // The socket objects will be deleted when this function exits, closing the
824 if (base::SyncSocket::CreatePair(sockets)) { 824 // handles. Any uses of the socket must duplicate them.
825 // The socket objects will be deleted when this function exits, closing the 825 scoped_ptr<base::SyncSocket> broker_socket(new base::SyncSocket());
826 // handles. Any uses of the socket must duplicate them. 826 scoped_ptr<base::SyncSocket> plugin_socket(new base::SyncSocket());
827 scoped_ptr<base::SyncSocket> broker_socket(sockets[0]); 827 if (base::SyncSocket::CreatePair(broker_socket.get(), plugin_socket.get())) {
828 scoped_ptr<base::SyncSocket> plugin_socket(sockets[1]);
829
830 result = dispatcher_->SendHandleToBroker(client->pp_instance(), 828 result = dispatcher_->SendHandleToBroker(client->pp_instance(),
831 broker_socket->handle()); 829 broker_socket->handle());
832 830
833 // If the broker has its pipe handle, duplicate the plugin's handle. 831 // If the broker has its pipe handle, duplicate the plugin's handle.
834 // Otherwise, the plugin's handle will be automatically closed. 832 // Otherwise, the plugin's handle will be automatically closed.
835 if (result == PP_OK) 833 if (result == PP_OK)
836 plugin_handle = DuplicateHandle(plugin_socket->handle()); 834 plugin_handle = DuplicateHandle(plugin_socket->handle());
837 } else { 835 } else {
838 result = PP_ERROR_FAILED; 836 result = PP_ERROR_FAILED;
839 } 837 }
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 2163
2166 bool PepperPluginDelegateImpl::CanUseSocketAPIs() { 2164 bool PepperPluginDelegateImpl::CanUseSocketAPIs() {
2167 WebView* webview = render_view_->webview(); 2165 WebView* webview = render_view_->webview();
2168 WebFrame* main_frame = webview ? webview->mainFrame() : NULL; 2166 WebFrame* main_frame = webview ? webview->mainFrame() : NULL;
2169 GURL url(main_frame ? GURL(main_frame->document().url()) : GURL()); 2167 GURL url(main_frame ? GURL(main_frame->document().url()) : GURL());
2170 if (!url.is_valid()) 2168 if (!url.is_valid())
2171 return false; 2169 return false;
2172 2170
2173 return content::GetContentClient()->renderer()->AllowSocketAPI(url); 2171 return content::GetContentClient()->renderer()->AllowSocketAPI(url);
2174 } 2172 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/audio_sync_reader.cc ('k') | ipc/sync_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698