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

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

Issue 7740038: Use macros to define pepper interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ppb_core_proxy.h" 5 #include "ppapi/proxy/ppb_core_proxy.h"
6 6
7 #include <stdlib.h> // For malloc 7 #include <stdlib.h> // For malloc
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 const PPB_Core core_interface = { 69 const PPB_Core core_interface = {
70 &AddRefResource, 70 &AddRefResource,
71 &ReleaseResource, 71 &ReleaseResource,
72 &GetTime, 72 &GetTime,
73 &GetTimeTicks, 73 &GetTimeTicks,
74 &CallOnMainThread, 74 &CallOnMainThread,
75 &IsMainThread 75 &IsMainThread
76 }; 76 };
77 77
78 InterfaceProxy* CreateCoreProxy(Dispatcher* dispatcher,
79 const void* target_interface) {
80 return new PPB_Core_Proxy(dispatcher, target_interface);
81 }
82
83 } // namespace 78 } // namespace
84 79
85 PPB_Core_Proxy::PPB_Core_Proxy(Dispatcher* dispatcher, 80 PPB_Core_Proxy::PPB_Core_Proxy(Dispatcher* dispatcher)
86 const void* target_interface) 81 : InterfaceProxy(dispatcher),
87 : InterfaceProxy(dispatcher, target_interface) { 82 ppb_core_impl_(NULL) {
83 if (!dispatcher->IsPlugin()) {
84 ppb_core_impl_ = static_cast<const PPB_Core*>(
85 dispatcher->local_get_interface()(PPB_CORE_INTERFACE));
86 }
88 } 87 }
89 88
90 PPB_Core_Proxy::~PPB_Core_Proxy() { 89 PPB_Core_Proxy::~PPB_Core_Proxy() {
91 } 90 }
92 91
93 // static 92 // static
94 const InterfaceProxy::Info* PPB_Core_Proxy::GetInfo() { 93 const PPB_Core* PPB_Core_Proxy::GetPPB_Core_Interface() {
95 static const Info info = { 94 return &core_interface;
96 &core_interface,
97 PPB_CORE_INTERFACE,
98 INTERFACE_ID_PPB_CORE,
99 false,
100 &CreateCoreProxy,
101 };
102 return &info;
103 } 95 }
104 96
105 bool PPB_Core_Proxy::OnMessageReceived(const IPC::Message& msg) { 97 bool PPB_Core_Proxy::OnMessageReceived(const IPC::Message& msg) {
106 bool handled = true; 98 bool handled = true;
107 IPC_BEGIN_MESSAGE_MAP(PPB_Core_Proxy, msg) 99 IPC_BEGIN_MESSAGE_MAP(PPB_Core_Proxy, msg)
108 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCore_AddRefResource, 100 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCore_AddRefResource,
109 OnMsgAddRefResource) 101 OnMsgAddRefResource)
110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCore_ReleaseResource, 102 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCore_ReleaseResource,
111 OnMsgReleaseResource) 103 OnMsgReleaseResource)
112 IPC_MESSAGE_UNHANDLED(handled = false) 104 IPC_MESSAGE_UNHANDLED(handled = false)
113 IPC_END_MESSAGE_MAP() 105 IPC_END_MESSAGE_MAP()
114 // TODO(brettw) handle bad messages! 106 // TODO(brettw) handle bad messages!
115 return handled; 107 return handled;
116 } 108 }
117 109
118 void PPB_Core_Proxy::OnMsgAddRefResource(const HostResource& resource) { 110 void PPB_Core_Proxy::OnMsgAddRefResource(const HostResource& resource) {
119 ppb_core_target()->AddRefResource(resource.host_resource()); 111 ppb_core_impl_->AddRefResource(resource.host_resource());
120 } 112 }
121 113
122 void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) { 114 void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) {
123 ppb_core_target()->ReleaseResource(resource.host_resource()); 115 ppb_core_impl_->ReleaseResource(resource.host_resource());
124 } 116 }
125 117
126 } // namespace proxy 118 } // namespace proxy
127 } // namespace ppapi 119 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698