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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_network_proxy_host.cc

Issue 105553005: Make PepperWebPlugin not use RenderViews. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 7 years 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/renderer_host/pepper/pepper_network_proxy_host.h" 5 #include "content/browser/renderer_host/pepper/pepper_network_proxy_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" 8 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
9 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h" 9 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 12 matching lines...) Expand all
23 namespace content { 23 namespace content {
24 24
25 PepperNetworkProxyHost::PepperNetworkProxyHost(BrowserPpapiHostImpl* host, 25 PepperNetworkProxyHost::PepperNetworkProxyHost(BrowserPpapiHostImpl* host,
26 PP_Instance instance, 26 PP_Instance instance,
27 PP_Resource resource) 27 PP_Resource resource)
28 : ResourceHost(host->GetPpapiHost(), instance, resource), 28 : ResourceHost(host->GetPpapiHost(), instance, resource),
29 proxy_service_(NULL), 29 proxy_service_(NULL),
30 is_allowed_(false), 30 is_allowed_(false),
31 waiting_for_ui_thread_data_(true), 31 waiting_for_ui_thread_data_(true),
32 weak_factory_(this) { 32 weak_factory_(this) {
33 int render_process_id(0), render_view_id(0); 33 int render_process_id(0), render_frame_id(0);
34 host->GetRenderViewIDsForInstance(instance, 34 host->GetRenderFrameIDsForInstance(instance,
35 &render_process_id, 35 &render_process_id,
36 &render_view_id); 36 &render_frame_id);
37 BrowserThread::PostTaskAndReplyWithResult( 37 BrowserThread::PostTaskAndReplyWithResult(
38 BrowserThread::UI, FROM_HERE, 38 BrowserThread::UI, FROM_HERE,
39 base::Bind(&GetUIThreadDataOnUIThread, 39 base::Bind(&GetUIThreadDataOnUIThread,
40 render_process_id, 40 render_process_id,
41 render_view_id, 41 render_frame_id,
42 host->external_plugin()), 42 host->external_plugin()),
43 base::Bind(&PepperNetworkProxyHost::DidGetUIThreadData, 43 base::Bind(&PepperNetworkProxyHost::DidGetUIThreadData,
44 weak_factory_.GetWeakPtr())); 44 weak_factory_.GetWeakPtr()));
45 } 45 }
46 46
47 PepperNetworkProxyHost::~PepperNetworkProxyHost() { 47 PepperNetworkProxyHost::~PepperNetworkProxyHost() {
48 while (!pending_requests_.empty()) { 48 while (!pending_requests_.empty()) {
49 // If the proxy_service_ is NULL, we shouldn't have any outstanding 49 // If the proxy_service_ is NULL, we shouldn't have any outstanding
50 // requests. 50 // requests.
51 DCHECK(proxy_service_); 51 DCHECK(proxy_service_);
52 net::ProxyService::PacRequest* request = pending_requests_.front(); 52 net::ProxyService::PacRequest* request = pending_requests_.front();
53 proxy_service_->CancelPacRequest(request); 53 proxy_service_->CancelPacRequest(request);
54 pending_requests_.pop(); 54 pending_requests_.pop();
55 } 55 }
56 } 56 }
57 57
58 PepperNetworkProxyHost::UIThreadData::UIThreadData() 58 PepperNetworkProxyHost::UIThreadData::UIThreadData()
59 : is_allowed(false) { 59 : is_allowed(false) {
60 } 60 }
61 61
62 PepperNetworkProxyHost::UIThreadData::~UIThreadData() { 62 PepperNetworkProxyHost::UIThreadData::~UIThreadData() {
63 } 63 }
64 64
65 // static 65 // static
66 PepperNetworkProxyHost::UIThreadData 66 PepperNetworkProxyHost::UIThreadData
67 PepperNetworkProxyHost::GetUIThreadDataOnUIThread(int render_process_id, 67 PepperNetworkProxyHost::GetUIThreadDataOnUIThread(int render_process_id,
68 int render_view_id, 68 int render_frame_id,
69 bool is_external_plugin) { 69 bool is_external_plugin) {
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
71 PepperNetworkProxyHost::UIThreadData result; 71 PepperNetworkProxyHost::UIThreadData result;
72 RenderProcessHost* render_process_host = 72 RenderProcessHost* render_process_host =
73 RenderProcessHost::FromID(render_process_id); 73 RenderProcessHost::FromID(render_process_id);
74 if (render_process_host && render_process_host->GetBrowserContext()) { 74 if (render_process_host && render_process_host->GetBrowserContext()) {
75 result.context_getter = render_process_host->GetBrowserContext()-> 75 result.context_getter = render_process_host->GetBrowserContext()->
76 GetRequestContextForRenderProcess(render_process_id); 76 GetRequestContextForRenderProcess(render_process_id);
77 } 77 }
78 78
79 RenderViewHost* render_view_host = 79 SocketPermissionRequest request(
80 RenderViewHost::FromID(render_process_id, render_view_id); 80 content::SocketPermissionRequest::RESOLVE_PROXY, std::string(), 0);
81 if (render_view_host) { 81 result.is_allowed = pepper_socket_utils::CanUseSocketAPIs(
82 SocketPermissionRequest request( 82 is_external_plugin,
83 content::SocketPermissionRequest::RESOLVE_PROXY, std::string(), 0); 83 false /* is_private_api */,
84 result.is_allowed = pepper_socket_utils::CanUseSocketAPIs( 84 &request,
85 is_external_plugin, 85 render_process_id,
86 false /* is_private_api */, 86 render_frame_id);
87 &request,
88 render_view_host);
89 }
90 return result; 87 return result;
91 } 88 }
92 89
93 void PepperNetworkProxyHost::DidGetUIThreadData( 90 void PepperNetworkProxyHost::DidGetUIThreadData(
94 const UIThreadData& ui_thread_data) { 91 const UIThreadData& ui_thread_data) {
95 is_allowed_ = ui_thread_data.is_allowed; 92 is_allowed_ = ui_thread_data.is_allowed;
96 if (ui_thread_data.context_getter.get() && 93 if (ui_thread_data.context_getter.get() &&
97 ui_thread_data.context_getter->GetURLRequestContext()) { 94 ui_thread_data.context_getter->GetURLRequestContext()) {
98 proxy_service_ = 95 proxy_service_ =
99 ui_thread_data.context_getter->GetURLRequestContext()->proxy_service(); 96 ui_thread_data.context_getter->GetURLRequestContext()->proxy_service();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 void PepperNetworkProxyHost::SendFailureReply( 183 void PepperNetworkProxyHost::SendFailureReply(
187 int32_t error, 184 int32_t error,
188 ppapi::host::ReplyMessageContext context) { 185 ppapi::host::ReplyMessageContext context) {
189 context.params.set_result(error); 186 context.params.set_result(error);
190 host()->SendReply(context, 187 host()->SendReply(context,
191 PpapiPluginMsg_NetworkProxy_GetProxyForURLReply( 188 PpapiPluginMsg_NetworkProxy_GetProxyForURLReply(
192 std::string())); 189 std::string()));
193 } 190 }
194 191
195 } // namespace content 192 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698