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

Side by Side Diff: ppapi/proxy/proxy_non_thread_safe_ref_count.h

Issue 10696157: Add support for threadsafe completion callback factory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698