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

Side by Side Diff: content/renderer/pepper/pepper_in_process_router.cc

Issue 225903006: PPAPI: Run clang_format.py on content/renderer/pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 8 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 #include "content/renderer/pepper/pepper_in_process_router.h" 5 #include "content/renderer/pepper/pepper_in_process_router.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "content/public/renderer/render_thread.h" 9 #include "content/public/renderer/render_thread.h"
10 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" 10 #include "content/renderer/pepper/renderer_ppapi_host_impl.h"
(...skipping 16 matching lines...) Expand all
27 virtual ~Channel() {} 27 virtual ~Channel() {}
28 28
29 virtual bool Send(IPC::Message* message) OVERRIDE { 29 virtual bool Send(IPC::Message* message) OVERRIDE {
30 return callback_.Run(message); 30 return callback_.Run(message);
31 } 31 }
32 32
33 private: 33 private:
34 base::Callback<bool(IPC::Message*)> callback_; 34 base::Callback<bool(IPC::Message*)> callback_;
35 }; 35 };
36 36
37 PepperInProcessRouter::PepperInProcessRouter( 37 PepperInProcessRouter::PepperInProcessRouter(RendererPpapiHostImpl* host_impl)
38 RendererPpapiHostImpl* host_impl)
39 : host_impl_(host_impl), 38 : host_impl_(host_impl),
40 pending_message_id_(0), 39 pending_message_id_(0),
41 reply_result_(false), 40 reply_result_(false),
42 weak_factory_(this) { 41 weak_factory_(this) {
43 browser_channel_.reset( 42 browser_channel_.reset(new Channel(base::Bind(
44 new Channel(base::Bind(&PepperInProcessRouter::SendToBrowser, 43 &PepperInProcessRouter::SendToBrowser, base::Unretained(this))));
45 base::Unretained(this)))); 44 host_to_plugin_router_.reset(new Channel(base::Bind(
46 host_to_plugin_router_.reset( 45 &PepperInProcessRouter::SendToPlugin, base::Unretained(this))));
47 new Channel(base::Bind(&PepperInProcessRouter::SendToPlugin, 46 plugin_to_host_router_.reset(new Channel(
48 base::Unretained(this)))); 47 base::Bind(&PepperInProcessRouter::SendToHost, base::Unretained(this))));
49 plugin_to_host_router_.reset(
50 new Channel(base::Bind(&PepperInProcessRouter::SendToHost,
51 base::Unretained(this))));
52 } 48 }
53 49
54 PepperInProcessRouter::~PepperInProcessRouter() { 50 PepperInProcessRouter::~PepperInProcessRouter() {}
55 }
56 51
57 IPC::Sender* PepperInProcessRouter::GetPluginToRendererSender() { 52 IPC::Sender* PepperInProcessRouter::GetPluginToRendererSender() {
58 return plugin_to_host_router_.get(); 53 return plugin_to_host_router_.get();
59 } 54 }
60 55
61 IPC::Sender* PepperInProcessRouter::GetRendererToPluginSender() { 56 IPC::Sender* PepperInProcessRouter::GetRendererToPluginSender() {
62 return host_to_plugin_router_.get(); 57 return host_to_plugin_router_.get();
63 } 58 }
64 59
65 ppapi::proxy::Connection PepperInProcessRouter::GetPluginConnection( 60 ppapi::proxy::Connection PepperInProcessRouter::GetPluginConnection(
66 PP_Instance instance) { 61 PP_Instance instance) {
67 int routing_id = 0; 62 int routing_id = 0;
68 RenderFrame* frame = host_impl_->GetRenderFrameForInstance(instance); 63 RenderFrame* frame = host_impl_->GetRenderFrameForInstance(instance);
69 if (frame) 64 if (frame)
70 routing_id = frame->GetRoutingID(); 65 routing_id = frame->GetRoutingID();
71 return ppapi::proxy::Connection(browser_channel_.get(), 66 return ppapi::proxy::Connection(
72 plugin_to_host_router_.get(), 67 browser_channel_.get(), plugin_to_host_router_.get(), routing_id);
73 routing_id);
74 } 68 }
75 69
76 // static 70 // static
77 bool PepperInProcessRouter::OnPluginMsgReceived(const IPC::Message& msg) { 71 bool PepperInProcessRouter::OnPluginMsgReceived(const IPC::Message& msg) {
78 // Emulate the proxy by dispatching the relevant message here. 72 // Emulate the proxy by dispatching the relevant message here.
79 ppapi::proxy::ResourceMessageReplyParams reply_params; 73 ppapi::proxy::ResourceMessageReplyParams reply_params;
80 IPC::Message nested_msg; 74 IPC::Message nested_msg;
81 75
82 if (msg.type() == PpapiPluginMsg_ResourceReply::ID) { 76 if (msg.type() == PpapiPluginMsg_ResourceReply::ID) {
83 // Resource reply from the renderer (no routing id). 77 // Resource reply from the renderer (no routing id).
84 if (!UnpackMessage<PpapiPluginMsg_ResourceReply>(msg, &reply_params, 78 if (!UnpackMessage<PpapiPluginMsg_ResourceReply>(
85 &nested_msg)) { 79 msg, &reply_params, &nested_msg)) {
86 NOTREACHED(); 80 NOTREACHED();
87 return false; 81 return false;
88 } 82 }
89 } else if (msg.type() == PpapiHostMsg_InProcessResourceReply::ID) { 83 } else if (msg.type() == PpapiHostMsg_InProcessResourceReply::ID) {
90 // Resource reply from the browser (has a routing id). 84 // Resource reply from the browser (has a routing id).
91 if (!UnpackMessage<PpapiHostMsg_InProcessResourceReply>(msg, &reply_params, 85 if (!UnpackMessage<PpapiHostMsg_InProcessResourceReply>(
92 &nested_msg)) { 86 msg, &reply_params, &nested_msg)) {
93 NOTREACHED(); 87 NOTREACHED();
94 return false; 88 return false;
95 } 89 }
96 } else { 90 } else {
97 return false; 91 return false;
98 } 92 }
99 ppapi::Resource* resource = 93 ppapi::Resource* resource =
100 ppapi::PpapiGlobals::Get()->GetResourceTracker()->GetResource( 94 ppapi::PpapiGlobals::Get()->GetResourceTracker()->GetResource(
101 reply_params.pp_resource()); 95 reply_params.pp_resource());
102 // If the resource doesn't exist, it may have been destroyed so just ignore 96 // If the resource doesn't exist, it may have been destroyed so just ignore
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 void PepperInProcessRouter::DispatchHostMsg(IPC::Message* msg) { 158 void PepperInProcessRouter::DispatchHostMsg(IPC::Message* msg) {
165 bool handled = host_impl_->GetPpapiHost()->OnMessageReceived(*msg); 159 bool handled = host_impl_->GetPpapiHost()->OnMessageReceived(*msg);
166 DCHECK(handled); 160 DCHECK(handled);
167 } 161 }
168 162
169 void PepperInProcessRouter::DispatchPluginMsg(IPC::Message* msg) { 163 void PepperInProcessRouter::DispatchPluginMsg(IPC::Message* msg) {
170 bool handled = OnPluginMsgReceived(*msg); 164 bool handled = OnPluginMsgReceived(*msg);
171 DCHECK(handled); 165 DCHECK(handled);
172 } 166 }
173 167
174 bool PepperInProcessRouter::SendToBrowser(IPC::Message *msg) { 168 bool PepperInProcessRouter::SendToBrowser(IPC::Message* msg) {
175 return RenderThread::Get()->Send(msg); 169 return RenderThread::Get()->Send(msg);
176 } 170 }
177 171
178 } // namespace content 172 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_in_process_router.h ('k') | content/renderer/pepper/pepper_media_device_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698