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

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/proxy_var.h

Issue 10386080: Rename nacl::RefCounted to nacl::RefCountedThreadSafe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: License bump Created 8 years, 7 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 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_H_ 5 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_H_
6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_H_ 6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_H_
7 7
8 #include "native_client/src/include/nacl_macros.h" 8 #include "native_client/src/include/nacl_macros.h"
9 #include "native_client/src/include/nacl_memory.h" 9 #include "native_client/src/include/nacl_memory.h"
10 #include "native_client/src/include/ref_counted.h" 10 #include "native_client/src/include/ref_counted.h"
11 #include "ppapi/c/pp_var.h" 11 #include "ppapi/c/pp_var.h"
12 12
13 namespace ppapi_proxy { 13 namespace ppapi_proxy {
14 14
15 // Complex PP_Var types (such as strings) have a copy of the variant's contents 15 // Complex PP_Var types (such as strings) have a copy of the variant's contents
16 // cached by the proxy. This is done so that PP_Vars can be reference counted, 16 // cached by the proxy. This is done so that PP_Vars can be reference counted,
17 // and their contents accessed "locally" by NaCl modules without having to 17 // and their contents accessed "locally" by NaCl modules without having to
18 // perform a complete round trip to the browser for each such operation. 18 // perform a complete round trip to the browser for each such operation.
19 // 19 //
20 // Note: this class is intended to be sub-classed to handle specific content 20 // Note: this class is intended to be sub-classed to handle specific content
21 // types such as strings, dictionaries, or arrays. 21 // types such as strings, dictionaries, or arrays.
22 class ProxyVar : public nacl::RefCounted<ProxyVar> { 22 class ProxyVar : public nacl::RefCountedThreadSafe<ProxyVar> {
23 public: 23 public:
24 // The type of this cached object. Simple types (int, bool, etc.) are not 24 // The type of this cached object. Simple types (int, bool, etc.) are not
25 // cached. 25 // cached.
26 PP_VarType pp_var_type() const { return pp_var_type_; } 26 PP_VarType pp_var_type() const { return pp_var_type_; }
27 27
28 // The assigned unique id associated with this object. Use this as the id 28 // The assigned unique id associated with this object. Use this as the id
29 // for the corresponding PP_Var. 29 // for the corresponding PP_Var.
30 int64_t id() const { return id_; } 30 int64_t id() const { return id_; }
31 31
32 protected: 32 protected:
33 // Initialize this instance to represent a PP_Var of type |pp_var_type|. 33 // Initialize this instance to represent a PP_Var of type |pp_var_type|.
34 // Generates a unique id for this instance, and sets the reference count to 1. 34 // Generates a unique id for this instance, and sets the reference count to 1.
35 // Subclasses should implement ctors that handle specific content data. 35 // Subclasses should implement ctors that handle specific content data.
36 explicit ProxyVar(PP_VarType pp_var_type); 36 explicit ProxyVar(PP_VarType pp_var_type);
37 37
38 virtual ~ProxyVar() {} 38 virtual ~ProxyVar() {}
39 39
40 private: 40 private:
41 friend class nacl::RefCounted<ProxyVar>; 41 friend class nacl::RefCountedThreadSafe<ProxyVar>;
42
42 PP_VarType pp_var_type_; 43 PP_VarType pp_var_type_;
43 int64_t id_; 44 int64_t id_;
44 45
46 // A counter for unique ids.
47 static int64_t unique_var_id;
48
45 ProxyVar(); // Not implemented - do not use. 49 ProxyVar(); // Not implemented - do not use.
46 NACL_DISALLOW_COPY_AND_ASSIGN(ProxyVar); 50 NACL_DISALLOW_COPY_AND_ASSIGN(ProxyVar);
47
48 // A counter for unique ids.
49 static int64_t unique_var_id;
50 }; 51 };
51 52
52 typedef scoped_refptr<ProxyVar> SharedProxyVar; 53 typedef scoped_refptr<ProxyVar> SharedProxyVar;
53 54
54 } // namespace ppapi_proxy 55 } // namespace ppapi_proxy
55 56
56 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_H_ 57 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698