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

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

Issue 17094022: PPAPI: Add permissions checking for PPB_NetworkProxy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments Created 7 years, 6 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) 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_NETWORK_PROXY_HOST_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_NETWORK_PROXY_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_NETWORK_PROXY_HOST_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_NETWORK_PROXY_HOST_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
(...skipping 12 matching lines...) Expand all
23 namespace ppapi { 23 namespace ppapi {
24 namespace host { 24 namespace host {
25 struct ReplyMessageContext; 25 struct ReplyMessageContext;
26 } 26 }
27 } 27 }
28 28
29 namespace content { 29 namespace content {
30 30
31 class BrowserPpapiHost; 31 class BrowserPpapiHost;
32 32
33 // The host for PPB_NetworkProxy. This class runs exclusively on the IO thread. 33 // The host for PPB_NetworkProxy. This class lives on the IO thread.
34 class CONTENT_EXPORT PepperNetworkProxyHost : public ppapi::host::ResourceHost { 34 class CONTENT_EXPORT PepperNetworkProxyHost : public ppapi::host::ResourceHost {
35 public: 35 public:
36 PepperNetworkProxyHost(BrowserPpapiHost* host, 36 PepperNetworkProxyHost(BrowserPpapiHost* host,
37 PP_Instance instance, 37 PP_Instance instance,
38 PP_Resource resource); 38 PP_Resource resource);
39 39
40 virtual ~PepperNetworkProxyHost(); 40 virtual ~PepperNetworkProxyHost();
41 41
42 private: 42 private:
43 // We retrieve the appropriate URLRequestContextGetter on the UI thread 43 // We retrieve the appropriate URLRequestContextGetter and whether this API
44 // and pass it to this function, which uses it to retrieve proxy_service_. 44 // is allowed for the instance on the UI thread and pass those to
45 void DidGetURLRequestContextGetter( 45 // DidGetUIThreadData, which sets allowed_ and proxy_service_.
46 scoped_refptr<net::URLRequestContextGetter> context_getter); 46 struct UIThreadData {
47 UIThreadData();
yzshen1 2013/06/21 18:06:24 I suspect you will get a warning of not having a d
dmichael (off chromium) 2013/06/21 20:25:45 The compiler provides the destructor for you by de
yzshen1 2013/06/21 20:31:35 Yeah, I know. I just vaguely remember that clang w
48 bool is_allowed;
49 scoped_refptr<net::URLRequestContextGetter> context_getter;
50 };
51 static UIThreadData GetUIThreadDataOnUIThread(int render_process_id,
52 int render_view_id,
53 bool is_external_plugin);
54 void DidGetUIThreadData(const UIThreadData&);
47 55
48 // ResourceHost implementation. 56 // ResourceHost implementation.
49 virtual int32_t OnResourceMessageReceived( 57 virtual int32_t OnResourceMessageReceived(
50 const IPC::Message& msg, 58 const IPC::Message& msg,
51 ppapi::host::HostMessageContext* context) OVERRIDE; 59 ppapi::host::HostMessageContext* context) OVERRIDE;
52 60
53 int32_t OnMsgGetProxyForURL(ppapi::host::HostMessageContext* context, 61 int32_t OnMsgGetProxyForURL(ppapi::host::HostMessageContext* context,
54 const std::string& url); 62 const std::string& url);
55 63
56 // If we have a valid proxy_service_, send all messages in unsent_requests_. 64 // If we have a valid proxy_service_, send all messages in unsent_requests_.
57 void TryToSendUnsentRequests(); 65 void TryToSendUnsentRequests();
58 66
59 void OnResolveProxyCompleted(ppapi::host::ReplyMessageContext context, 67 void OnResolveProxyCompleted(ppapi::host::ReplyMessageContext context,
60 net::ProxyInfo* proxy_info, 68 net::ProxyInfo* proxy_info,
61 int result); 69 int result);
62 void SendFailureReply(int32_t error, 70 void SendFailureReply(int32_t error,
63 ppapi::host::ReplyMessageContext context); 71 ppapi::host::ReplyMessageContext context);
64 72
73 // The following two members are invalid until we get some information from
74 // the UI thread. However, these are only ever set or accessed on the IO
75 // thread.
65 net::ProxyService* proxy_service_; 76 net::ProxyService* proxy_service_;
66 bool waiting_for_proxy_service_; 77 bool is_allowed_;
78
79 // False initially, but set to true once the values for proxy_service_ and
yzshen1 2013/06/21 18:06:24 Is this comment inverted? It is set to false when
dmichael (off chromium) 2013/06/21 20:25:45 Oops! Thanks, nice catch.
80 // is_allowed_ have been set.
81 bool waiting_for_ui_thread_data_;
67 82
68 // We have to get the URLRequestContextGetter from the UI thread before we 83 // We have to get the URLRequestContextGetter from the UI thread before we
69 // can retrieve proxy_service_. If we receive any calls for GetProxyForURL 84 // can retrieve proxy_service_. If we receive any calls for GetProxyForURL
70 // before proxy_service_ is available, we save them in unsent_requests_. 85 // before proxy_service_ is available, we save them in unsent_requests_.
71 struct UnsentRequest { 86 struct UnsentRequest {
72 GURL url; 87 GURL url;
73 ppapi::host::ReplyMessageContext reply_context; 88 ppapi::host::ReplyMessageContext reply_context;
74 }; 89 };
75 std::queue<UnsentRequest> unsent_requests_; 90 std::queue<UnsentRequest> unsent_requests_;
76 91
77 // Requests awaiting a response from ProxyService. We need to store these so 92 // Requests awaiting a response from ProxyService. We need to store these so
78 // that we can cancel them if we get destroyed. 93 // that we can cancel them if we get destroyed.
79 std::queue<net::ProxyService::PacRequest*> pending_requests_; 94 std::queue<net::ProxyService::PacRequest*> pending_requests_;
80 95
81 base::WeakPtrFactory<PepperNetworkProxyHost> weak_factory_; 96 base::WeakPtrFactory<PepperNetworkProxyHost> weak_factory_;
82 97
83 DISALLOW_COPY_AND_ASSIGN(PepperNetworkProxyHost); 98 DISALLOW_COPY_AND_ASSIGN(PepperNetworkProxyHost);
84 }; 99 };
85 100
86 } // namespace content 101 } // namespace content
87 102
88 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_NETWORK_PROXY_HOST_H_ 103 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_NETWORK_PROXY_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698