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

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

Issue 10909138: Convert the async device ID getter to a chrome resource host (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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
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/browser/renderer_host/pepper/browser_ppapi_host_impl.h" 5 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
6 6
7 #include "content/public/browser/browser_thread.h"
8 #include "content/public/browser/render_view_host.h"
7 #include "ipc/ipc_message_macros.h" 9 #include "ipc/ipc_message_macros.h"
8 10
9 namespace content { 11 namespace content {
10 12
11 BrowserPpapiHostImpl::BrowserPpapiHostImpl( 13 BrowserPpapiHostImpl::BrowserPpapiHostImpl(
12 IPC::Sender* sender, 14 IPC::Sender* sender,
13 const ppapi::PpapiPermissions& permissions) 15 const ppapi::PpapiPermissions& permissions)
14 : host_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 16 : ppapi_host_(sender, permissions),
15 ppapi_host_(sender, &host_factory_, permissions),
16 plugin_process_handle_(base::kNullProcessHandle) { 17 plugin_process_handle_(base::kNullProcessHandle) {
18 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
19 new ContentBrowserPepperHostFactory(this)));
17 } 20 }
18 21
19 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { 22 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() {
20 } 23 }
21 24
22 bool BrowserPpapiHostImpl::OnMessageReceived(const IPC::Message& msg) { 25 bool BrowserPpapiHostImpl::OnMessageReceived(const IPC::Message& msg) {
23 /* TODO(brettw) when we add messages, here, the code should look like this: 26 /* TODO(brettw) when we add messages, here, the code should look like this:
24 bool handled = true; 27 bool handled = true;
25 IPC_BEGIN_MESSAGE_MAP(BrowserPpapiHostImpl, msg) 28 IPC_BEGIN_MESSAGE_MAP(BrowserPpapiHostImpl, msg)
26 // Add necessary message handlers here. 29 // Add necessary message handlers here.
27 IPC_MESSAGE_UNHANDLED(handled = ppapi_host_.OnMessageReceived(msg)) 30 IPC_MESSAGE_UNHANDLED(handled = ppapi_host_.OnMessageReceived(msg))
28 IPC_END_MESSAGE_MAP(); 31 IPC_END_MESSAGE_MAP();
29 return handled; 32 return handled;
30 */ 33 */
31 return ppapi_host_.OnMessageReceived(msg); 34 return ppapi_host_.OnMessageReceived(msg);
32 } 35 }
33 36
34 ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() { 37 ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() {
35 return &ppapi_host_; 38 return &ppapi_host_;
36 } 39 }
37 40
38 base::ProcessHandle BrowserPpapiHostImpl::GetPluginProcessHandle() const { 41 base::ProcessHandle BrowserPpapiHostImpl::GetPluginProcessHandle() const {
39 // Handle should previously have been set before use. 42 // Handle should previously have been set before use.
40 DCHECK(plugin_process_handle_ != base::kNullProcessHandle); 43 DCHECK(plugin_process_handle_ != base::kNullProcessHandle);
41 return plugin_process_handle_; 44 return plugin_process_handle_;
42 } 45 }
43 46
47 bool BrowserPpapiHostImpl::IsValidInstance(PP_Instance instance) const {
48 return instance_to_view_.find(instance) != instance_to_view_.end();
49 }
50
51 bool BrowserPpapiHostImpl::GetRenderViewIDsForInstance(
52 PP_Instance instance,
53 int* render_process_id,
54 int* render_view_id) const {
55 InstanceToViewMap::const_iterator found = instance_to_view_.find(instance);
56 if (found == instance_to_view_.end()) {
57 *render_process_id = 0;
58 *render_view_id = 0;
59 return false;
60 }
61
62 *render_process_id = found->second.process_id;
63 *render_view_id = found->second.view_id;
64 return true;
65 }
66
67 void BrowserPpapiHostImpl::AddInstanceForView(PP_Instance instance,
68 int render_process_id,
69 int render_view_id) {
70 DCHECK(instance_to_view_.find(instance) == instance_to_view_.end());
71
72 RenderViewIDs ids;
73 ids.process_id = render_process_id;
74 ids.view_id = render_view_id;
75 instance_to_view_[instance] = ids;
76 }
77
78 void BrowserPpapiHostImpl::DeleteInstanceForView(PP_Instance instance) {
79 InstanceToViewMap::iterator found = instance_to_view_.find(instance);
80 if (found == instance_to_view_.end()) {
81 NOTREACHED();
82 return;
83 }
84 instance_to_view_.erase(found);
85 }
86
44 } // namespace content 87 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698