OLD | NEW |
---|---|
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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 GetMainThreadMessageLoop()->PostDelayedTask( | 62 GetMainThreadMessageLoop()->PostDelayedTask( |
63 FROM_HERE, | 63 FROM_HERE, |
64 NewRunnableFunction(callback.func, callback.user_data, result), | 64 NewRunnableFunction(callback.func, callback.user_data, result), |
65 delay_in_ms); | 65 delay_in_ms); |
66 } | 66 } |
67 | 67 |
68 PP_Bool IsMainThread() { | 68 PP_Bool IsMainThread() { |
69 return PP_FromBool(GetMainThreadMessageLoop()->BelongsToCurrentThread()); | 69 return PP_FromBool(GetMainThreadMessageLoop()->BelongsToCurrentThread()); |
70 } | 70 } |
71 | 71 |
72 const PPB_Core core_interface = { | |
73 &AddRefResource, | |
74 &ReleaseResource, | |
75 &MemAlloc, | |
76 &MemFree, | |
77 &GetTime, | |
78 &GetTimeTicks, | |
79 &CallOnMainThread, | |
80 &IsMainThread | |
81 }; | |
82 | |
83 InterfaceProxy* CreateCoreProxy(Dispatcher* dispatcher, | 72 InterfaceProxy* CreateCoreProxy(Dispatcher* dispatcher, |
84 const void* target_interface) { | 73 const void* target_interface) { |
85 return new PPB_Core_Proxy(dispatcher, target_interface); | 74 return new PPB_Core_Proxy(dispatcher, target_interface); |
86 } | 75 } |
87 | 76 |
88 } // namespace | 77 } // namespace |
89 | 78 |
90 PPB_Core_Proxy::PPB_Core_Proxy(Dispatcher* dispatcher, | 79 PPB_Core_Proxy::PPB_Core_Proxy(Dispatcher* dispatcher, |
91 const void* target_interface) | 80 const void* target_interface) |
92 : InterfaceProxy(dispatcher, target_interface) { | 81 : InterfaceProxy(dispatcher, target_interface) { |
93 } | 82 } |
94 | 83 |
95 PPB_Core_Proxy::~PPB_Core_Proxy() { | 84 PPB_Core_Proxy::~PPB_Core_Proxy() { |
96 } | 85 } |
97 | 86 |
98 // static | 87 // static |
99 const InterfaceProxy::Info* PPB_Core_Proxy::GetInfo() { | 88 const InterfaceProxy::Info* PPB_Core_Proxy::GetInfo() { |
89 static const PPB_Core core_interface = { | |
90 &AddRefResource, | |
91 &ReleaseResource, | |
92 &GetTime, | |
93 &GetTimeTicks, | |
94 &CallOnMainThread, | |
95 &IsMainThread | |
96 }; | |
dmichael (off chromium)
2011/07/14 05:28:21
I'm not sure moving it here buys you much. I guess
Matt Ball
2011/07/14 15:49:20
Done.
| |
97 | |
100 static const Info info = { | 98 static const Info info = { |
101 &core_interface, | 99 &core_interface, |
102 PPB_CORE_INTERFACE, | 100 PPB_CORE_INTERFACE, |
103 INTERFACE_ID_PPB_CORE, | 101 INTERFACE_ID_PPB_CORE, |
104 false, | 102 false, |
105 &CreateCoreProxy, | 103 &CreateCoreProxy, |
106 }; | 104 }; |
107 return &info; | 105 return &info; |
108 } | 106 } |
109 | 107 |
(...skipping 13 matching lines...) Expand all Loading... | |
123 void PPB_Core_Proxy::OnMsgAddRefResource(HostResource resource) { | 121 void PPB_Core_Proxy::OnMsgAddRefResource(HostResource resource) { |
124 ppb_core_target()->AddRefResource(resource.host_resource()); | 122 ppb_core_target()->AddRefResource(resource.host_resource()); |
125 } | 123 } |
126 | 124 |
127 void PPB_Core_Proxy::OnMsgReleaseResource(HostResource resource) { | 125 void PPB_Core_Proxy::OnMsgReleaseResource(HostResource resource) { |
128 ppb_core_target()->ReleaseResource(resource.host_resource()); | 126 ppb_core_target()->ReleaseResource(resource.host_resource()); |
129 } | 127 } |
130 | 128 |
131 } // namespace proxy | 129 } // namespace proxy |
132 } // namespace pp | 130 } // namespace pp |
OLD | NEW |