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

Side by Side Diff: ppapi/proxy/dispatcher.cc

Issue 245443005: Move IPC::MessageFilter and router to a separate file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix gn build 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
« no previous file with comments | « ppapi/proxy/dispatcher.h ('k') | ppapi/proxy/host_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ppapi/proxy/dispatcher.h" 5 #include "ppapi/proxy/dispatcher.h"
6 6
7 #include <string.h> // For memset. 7 #include <string.h> // For memset.
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "ppapi/proxy/ppapi_messages.h" 14 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/proxy/var_serialization_rules.h" 15 #include "ppapi/proxy/var_serialization_rules.h"
16 16
17 namespace IPC {
18 class MessageFilter;
19 }
20
17 namespace ppapi { 21 namespace ppapi {
18 namespace proxy { 22 namespace proxy {
19 23
20 Dispatcher::Dispatcher(PP_GetInterface_Func local_get_interface, 24 Dispatcher::Dispatcher(PP_GetInterface_Func local_get_interface,
21 const PpapiPermissions& permissions) 25 const PpapiPermissions& permissions)
22 : local_get_interface_(local_get_interface), 26 : local_get_interface_(local_get_interface),
23 permissions_(permissions) { 27 permissions_(permissions) {
24 } 28 }
25 29
26 Dispatcher::~Dispatcher() { 30 Dispatcher::~Dispatcher() {
27 } 31 }
28 32
29 InterfaceProxy* Dispatcher::GetInterfaceProxy(ApiID id) { 33 InterfaceProxy* Dispatcher::GetInterfaceProxy(ApiID id) {
30 InterfaceProxy* proxy = proxies_[id].get(); 34 InterfaceProxy* proxy = proxies_[id].get();
31 if (!proxy) { 35 if (!proxy) {
32 // Handle the first time for a given API by creating the proxy for it. 36 // Handle the first time for a given API by creating the proxy for it.
33 InterfaceProxy::Factory factory = 37 InterfaceProxy::Factory factory =
34 InterfaceList::GetInstance()->GetFactoryForID(id); 38 InterfaceList::GetInstance()->GetFactoryForID(id);
35 if (!factory) { 39 if (!factory) {
36 NOTREACHED(); 40 NOTREACHED();
37 return NULL; 41 return NULL;
38 } 42 }
39 proxy = factory(this); 43 proxy = factory(this);
40 DCHECK(proxy); 44 DCHECK(proxy);
41 proxies_[id].reset(proxy); 45 proxies_[id].reset(proxy);
42 } 46 }
43 return proxy; 47 return proxy;
44 } 48 }
45 49
46 void Dispatcher::AddIOThreadMessageFilter( 50 void Dispatcher::AddIOThreadMessageFilter(IPC::MessageFilter* filter) {
47 IPC::ChannelProxy::MessageFilter* filter) {
48 // Our filter is refcounted. The channel will call the destruct method on the 51 // Our filter is refcounted. The channel will call the destruct method on the
49 // filter when the channel is done with it, so the corresponding Release() 52 // filter when the channel is done with it, so the corresponding Release()
50 // happens there. 53 // happens there.
51 channel()->AddFilter(filter); 54 channel()->AddFilter(filter);
52 } 55 }
53 56
54 bool Dispatcher::OnMessageReceived(const IPC::Message& msg) { 57 bool Dispatcher::OnMessageReceived(const IPC::Message& msg) {
55 if (msg.routing_id() <= 0 || msg.routing_id() >= API_ID_COUNT) { 58 if (msg.routing_id() <= 0 || msg.routing_id() >= API_ID_COUNT) {
56 OnInvalidMessageReceived(); 59 OnInvalidMessageReceived();
57 return true; 60 return true;
(...skipping 11 matching lines...) Expand all
69 void Dispatcher::SetSerializationRules( 72 void Dispatcher::SetSerializationRules(
70 VarSerializationRules* var_serialization_rules) { 73 VarSerializationRules* var_serialization_rules) {
71 serialization_rules_ = var_serialization_rules; 74 serialization_rules_ = var_serialization_rules;
72 } 75 }
73 76
74 void Dispatcher::OnInvalidMessageReceived() { 77 void Dispatcher::OnInvalidMessageReceived() {
75 } 78 }
76 79
77 } // namespace proxy 80 } // namespace proxy
78 } // namespace ppapi 81 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/dispatcher.h ('k') | ppapi/proxy/host_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698