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

Side by Side Diff: ppapi/shared_impl/var_tracker.h

Issue 8930010: Implement in-process PPB_VarArrayBuffer_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some pre-review cleanup. Created 9 years 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 PPAPI_SHARED_IMPL_VAR_TRACKER_H_ 5 #ifndef PPAPI_SHARED_IMPL_VAR_TRACKER_H_
6 #define PPAPI_SHARED_IMPL_VAR_TRACKER_H_ 6 #define PPAPI_SHARED_IMPL_VAR_TRACKER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/hash_tables.h" 9 #include "base/hash_tables.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "ppapi/c/pp_module.h"
11 #include "ppapi/c/pp_var.h" 12 #include "ppapi/c/pp_var.h"
12 #include "ppapi/shared_impl/ppapi_shared_export.h" 13 #include "ppapi/shared_impl/ppapi_shared_export.h"
13 14
14 namespace ppapi { 15 namespace ppapi {
15 16
17 class ArrayBufferVar;
16 class Var; 18 class Var;
17 19
18 // Tracks non-POD (refcounted) var objects held by a plugin. 20 // Tracks non-POD (refcounted) var objects held by a plugin.
19 // 21 //
20 // The tricky part is the concept of a "tracked object". These are only 22 // The tricky part is the concept of a "tracked object". These are only
21 // necessary in the plugin side of the proxy when running out of process. A 23 // necessary in the plugin side of the proxy when running out of process. A
22 // tracked object is one that the plugin is aware of, but doesn't hold a 24 // tracked object is one that the plugin is aware of, but doesn't hold a
23 // reference to. This will happen when the plugin is passed an object as an 25 // reference to. This will happen when the plugin is passed an object as an
24 // argument from the host (renderer) as an input argument to a sync function, 26 // argument from the host (renderer) as an input argument to a sync function,
25 // but where ownership is not passed. 27 // but where ownership is not passed.
(...skipping 21 matching lines...) Expand all
47 bool AddRefVar(int32 var_id); 49 bool AddRefVar(int32 var_id);
48 bool AddRefVar(const PP_Var& var); 50 bool AddRefVar(const PP_Var& var);
49 51
50 // Decreases the given Var ID's refcount, returning true on success, false if 52 // Decreases the given Var ID's refcount, returning true on success, false if
51 // the ID is invalid or if the refcount was already 0. The PP_Var version 53 // the ID is invalid or if the refcount was already 0. The PP_Var version
52 // returns true and does nothing for non-refcounted type vars. The var will 54 // returns true and does nothing for non-refcounted type vars. The var will
53 // be deleted if there are no more refs to it. 55 // be deleted if there are no more refs to it.
54 bool ReleaseVar(int32 var_id); 56 bool ReleaseVar(int32 var_id);
55 bool ReleaseVar(const PP_Var& var); 57 bool ReleaseVar(const PP_Var& var);
56 58
59 // Create a new array buffer of size |size_in_bytes|. Return a PP_Var that
60 // that references it and has an initial reference-count of 1.
61 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes);
62
57 protected: 63 protected:
58 struct VarInfo { 64 struct VarInfo {
59 VarInfo(); 65 VarInfo();
60 VarInfo(Var* v, int input_ref_count); 66 VarInfo(Var* v, int input_ref_count);
61 67
62 scoped_refptr<Var> var; 68 scoped_refptr<Var> var;
63 69
64 // Explicit reference count. This value is affected by the renderer calling 70 // Explicit reference count. This value is affected by the renderer calling
65 // AddRef and Release. A nonzero value here is represented by a single 71 // AddRef and Release. A nonzero value here is represented by a single
66 // reference in the host on our behalf (this reduces IPC traffic). 72 // reference in the host on our behalf (this reduces IPC traffic).
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // still alive. 125 // still alive.
120 // 126 //
121 // Overridden by the PluginVarTracker to also clean up the host info map. 127 // Overridden by the PluginVarTracker to also clean up the host info map.
122 virtual bool DeleteObjectInfoIfNecessary(VarMap::iterator iter); 128 virtual bool DeleteObjectInfoIfNecessary(VarMap::iterator iter);
123 129
124 VarMap live_vars_; 130 VarMap live_vars_;
125 131
126 // Last assigned var ID. 132 // Last assigned var ID.
127 int32 last_var_id_; 133 int32 last_var_id_;
128 134
135 private:
136 // Create and return a new ArrayBufferVar size_in_bytes bytes long. This is
137 // implemented by the Host and Plugin tracker separately, so that it can be
138 // a real WebKit ArrayBuffer on the host side.
139 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) = 0;
140
129 DISALLOW_COPY_AND_ASSIGN(VarTracker); 141 DISALLOW_COPY_AND_ASSIGN(VarTracker);
130 }; 142 };
131 143
132 } // namespace ppapi 144 } // namespace ppapi
133 145
134 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ 146 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698