OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef PPAPI_PROXY_PROXY_NON_THREAD_SAFE_REF_COUNT_H_ | |
6 #define PPAPI_PROXY_PROXY_NON_THREAD_SAFE_REF_COUNT_H_ | |
7 | |
8 #include "base/message_loop.h" | |
9 #include "ppapi/cpp/completion_callback.h" | |
10 | |
11 namespace ppapi { | |
12 namespace proxy { | |
13 | |
14 // This class is just like ppapi/cpp/non_thread_safe_ref_count.h but rather | |
15 // than using pp::Module::core (which doesn't exist), it uses Chrome threads | |
16 // which do. | |
17 class ProxyNonThreadSafeRefCount { | |
18 public: | |
19 ProxyNonThreadSafeRefCount() : ref_(0) { | |
20 #ifndef NDEBUG | |
21 message_loop_ = MessageLoop::current(); | |
22 #endif | |
23 } | |
24 | |
25 ~ProxyNonThreadSafeRefCount() { | |
26 PP_DCHECK(message_loop_ == MessageLoop::current()); | |
27 } | |
28 | |
29 int32_t AddRef() { | |
30 PP_DCHECK(message_loop_ == MessageLoop::current()); | |
31 return ++ref_; | |
32 } | |
33 | |
34 int32_t Release() { | |
35 PP_DCHECK(message_loop_ == MessageLoop::current()); | |
36 return --ref_; | |
37 } | |
38 | |
39 private: | |
40 int32_t ref_; | |
41 #ifndef NDEBUG | |
42 MessageLoop* message_loop_; | |
43 #endif | |
44 }; | |
45 | |
46 } // namespace proxy | |
47 } // namespace ppapi | |
48 | |
49 #endif // PPAPI_PROXY_PROXY_NON_THREAD_SAFE_REF_COUNT_H_ | |
OLD | NEW |