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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "ppapi/c/pp_completion_callback.h" | 15 #include "ppapi/c/pp_completion_callback.h" |
16 #include "ppapi/c/pp_resource.h" | 16 #include "ppapi/c/pp_resource.h" |
17 #include "ppapi/c/ppb_core.h" | 17 #include "ppapi/c/ppb_core.h" |
18 #include "ppapi/proxy/plugin_dispatcher.h" | 18 #include "ppapi/proxy/plugin_dispatcher.h" |
19 #include "ppapi/proxy/plugin_resource_tracker.h" | 19 #include "ppapi/proxy/plugin_resource_tracker.h" |
20 #include "ppapi/proxy/ppapi_messages.h" | 20 #include "ppapi/proxy/ppapi_messages.h" |
| 21 #include "ppapi/shared_impl/proxy_lock.h" |
21 #include "ppapi/shared_impl/time_conversion.h" | 22 #include "ppapi/shared_impl/time_conversion.h" |
22 | 23 |
23 namespace ppapi { | 24 namespace ppapi { |
24 namespace proxy { | 25 namespace proxy { |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 base::MessageLoopProxy* GetMainThreadMessageLoop() { | 29 base::MessageLoopProxy* GetMainThreadMessageLoop() { |
29 static scoped_refptr<base::MessageLoopProxy> proxy( | 30 static scoped_refptr<base::MessageLoopProxy> proxy( |
30 base::MessageLoopProxy::current()); | 31 base::MessageLoopProxy::current()); |
31 return proxy.get(); | 32 return proxy.get(); |
32 } | 33 } |
33 | 34 |
34 void AddRefResource(PP_Resource resource) { | 35 void AddRefResource(PP_Resource resource) { |
| 36 ppapi::ProxyAutoLock lock; |
35 PluginResourceTracker::GetInstance()->AddRefResource(resource); | 37 PluginResourceTracker::GetInstance()->AddRefResource(resource); |
36 } | 38 } |
37 | 39 |
38 void ReleaseResource(PP_Resource resource) { | 40 void ReleaseResource(PP_Resource resource) { |
| 41 ppapi::ProxyAutoLock lock; |
39 PluginResourceTracker::GetInstance()->ReleaseResource(resource); | 42 PluginResourceTracker::GetInstance()->ReleaseResource(resource); |
40 } | 43 } |
41 | 44 |
42 double GetTime() { | 45 double GetTime() { |
43 return TimeToPPTime(base::Time::Now()); | 46 return TimeToPPTime(base::Time::Now()); |
44 } | 47 } |
45 | 48 |
46 double GetTimeTicks() { | 49 double GetTimeTicks() { |
47 return TimeTicksToPPTimeTicks(base::TimeTicks::Now()); | 50 return TimeTicksToPPTimeTicks(base::TimeTicks::Now()); |
48 } | 51 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 void PPB_Core_Proxy::OnMsgAddRefResource(const HostResource& resource) { | 114 void PPB_Core_Proxy::OnMsgAddRefResource(const HostResource& resource) { |
112 ppb_core_impl_->AddRefResource(resource.host_resource()); | 115 ppb_core_impl_->AddRefResource(resource.host_resource()); |
113 } | 116 } |
114 | 117 |
115 void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) { | 118 void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) { |
116 ppb_core_impl_->ReleaseResource(resource.host_resource()); | 119 ppb_core_impl_->ReleaseResource(resource.host_resource()); |
117 } | 120 } |
118 | 121 |
119 } // namespace proxy | 122 } // namespace proxy |
120 } // namespace ppapi | 123 } // namespace ppapi |
OLD | NEW |