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

Side by Side Diff: content/public/browser/browser_ppapi_host.h

Issue 11441012: PPB_UDPSocket_Private is switched to the new Pepper proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PPB_UDPSocket_Shared is merged to UDPSocketPrivateResource. PepperUDPSocketPrivateShared is merged … Created 7 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) 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 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_ 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/process.h" 9 #include "base/process.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
14 #include "content/public/common/process_type.h"
13 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
14 #include "ppapi/c/pp_instance.h" 16 #include "ppapi/c/pp_instance.h"
15 17
16 namespace IPC { 18 namespace IPC {
17 class ChannelProxy; 19 class ChannelProxy;
18 struct ChannelHandle; 20 struct ChannelHandle;
19 class Sender; 21 class Sender;
20 } 22 }
21 23
22 namespace net { 24 namespace net {
(...skipping 15 matching lines...) Expand all
38 // There will be one of these objects in the browser per plugin process. It 40 // There will be one of these objects in the browser per plugin process. It
39 // lives entirely on the I/O thread. 41 // lives entirely on the I/O thread.
40 class CONTENT_EXPORT BrowserPpapiHost { 42 class CONTENT_EXPORT BrowserPpapiHost {
41 public: 43 public:
42 // Creates a browser host and sets up an out-of-process proxy for an external 44 // Creates a browser host and sets up an out-of-process proxy for an external
43 // pepper plugin process. 45 // pepper plugin process.
44 static BrowserPpapiHost* CreateExternalPluginProcess( 46 static BrowserPpapiHost* CreateExternalPluginProcess(
45 IPC::Sender* sender, 47 IPC::Sender* sender,
46 ppapi::PpapiPermissions permissions, 48 ppapi::PpapiPermissions permissions,
47 base::ProcessHandle plugin_child_process, 49 base::ProcessHandle plugin_child_process,
50 ProcessType process_type,
48 IPC::ChannelProxy* channel, 51 IPC::ChannelProxy* channel,
49 net::HostResolver* host_resolver, 52 net::HostResolver* host_resolver,
50 int render_process_id, 53 int render_process_id,
51 int render_view_id); 54 int render_view_id);
52 55
53 virtual ~BrowserPpapiHost() {} 56 virtual ~BrowserPpapiHost() {}
54 57
55 // Returns the PpapiHost object. 58 // Returns the PpapiHost object.
56 virtual ppapi::host::PpapiHost* GetPpapiHost() = 0; 59 virtual ppapi::host::PpapiHost* GetPpapiHost() = 0;
57 60
(...skipping 18 matching lines...) Expand all
76 79
77 // Returns the name of the plugin. 80 // Returns the name of the plugin.
78 virtual const std::string& GetPluginName() = 0; 81 virtual const std::string& GetPluginName() = 0;
79 82
80 // Returns the user's profile data directory. 83 // Returns the user's profile data directory.
81 virtual const FilePath& GetProfileDataDirectory() = 0; 84 virtual const FilePath& GetProfileDataDirectory() = 0;
82 85
83 // Get the Document/Plugin URLs for the given PP_Instance. 86 // Get the Document/Plugin URLs for the given PP_Instance.
84 virtual GURL GetDocumentURLForInstance(PP_Instance instance) = 0; 87 virtual GURL GetDocumentURLForInstance(PP_Instance instance) = 0;
85 virtual GURL GetPluginURLForInstance(PP_Instance instance) = 0; 88 virtual GURL GetPluginURLForInstance(PP_Instance instance) = 0;
89
90 // Schedules the given callback to execute on the UI thread of the browser,
91 // passing the RenderViewHost associated with the given instance as a
92 // parameter.
93 //
94 // Normally this would be called from a ResourceHost with the reply using
95 // a weak pointer to itself.
96 //
97 // Importantly, the task will not be run if the RenderView is destroyed by
98 // the time we get to the UI thread, or if the PP_Instance is invalid, but
99 // the reply will still be run. The return type in this case will be a
100 // default-constructed |ReturnType|.
101 //
102 // So you may want to make sure you don't do silly things in the reply
103 // handler if the task on the UI thread is never run and you get a
104 // default-constructed result.
105 template<typename ReturnType>
106 bool PostOnUIThreadWithRenderViewHostAndReply(
107 const tracked_objects::Location& from_here,
108 PP_Instance instance,
109 const base::Callback<ReturnType(RenderViewHost*)>& task,
110 const base::Callback<void(ReturnType)>& reply) const {
111 int render_process_id, render_view_id;
112 bool success = GetRenderViewIDsForInstance(instance,
113 &render_process_id,
114 &render_view_id);
115 if (!success)
116 return false;
117 BrowserThread::PostTaskAndReplyWithResult(
118 BrowserThread::UI,
119 from_here,
120 base::Bind(&CallWithRenderViewHost<ReturnType>,
121 render_process_id, render_view_id, task),
122 reply);
123 return true;
124 }
125
126 protected:
127 // Backend for PostOnUIThreadWithRenderViewAndReply. This converts the IDs
dmichael (off chromium) 2013/01/10 17:30:47 nit: PostOnUIThreadWithRenderView+Host+AndReply
ygorshenin1 2013/01/11 11:42:45 Done.
128 // to a RenderViewHost and calls the function, or returns a
129 // default-constructed return value on error.
130 template<typename ReturnType>
131 static ReturnType CallWithRenderViewHost(
132 int render_process_id,
133 int render_view_id,
134 const base::Callback<ReturnType(RenderViewHost*)>& task) {
135 RenderViewHost* render_view_host = RenderViewHost::FromID(render_process_id,
136 render_view_id);
137 if (render_view_host)
138 return task.Run(render_view_host);
139 return ReturnType();
140 }
86 }; 141 };
87 142
88 } // namespace content 143 } // namespace content
89 144
90 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_ 145 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698