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

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

Issue 10542150: Actually free plugin implement vars when running out of process when the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/threading/non_thread_safe.h" 13 #include "base/threading/non_thread_safe.h"
14 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_module.h" 15 #include "ppapi/c/pp_module.h"
15 #include "ppapi/c/pp_var.h" 16 #include "ppapi/c/pp_var.h"
16 #include "ppapi/shared_impl/ppapi_shared_export.h" 17 #include "ppapi/shared_impl/ppapi_shared_export.h"
17 18
18 namespace ppapi { 19 namespace ppapi {
19 20
20 class ArrayBufferVar; 21 class ArrayBufferVar;
21 class Var; 22 class Var;
22 23
23 // Tracks non-POD (refcounted) var objects held by a plugin. 24 // Tracks non-POD (refcounted) var objects held by a plugin.
24 // 25 //
25 // The tricky part is the concept of a "tracked object". These are only 26 // The tricky part is the concept of a "tracked object". These are only
26 // necessary in the plugin side of the proxy when running out of process. A 27 // necessary in the plugin side of the proxy when running out of process. A
27 // tracked object is one that the plugin is aware of, but doesn't hold a 28 // tracked object is one that the plugin is aware of, but doesn't hold a
28 // reference to. This will happen when the plugin is passed an object as an 29 // reference to. This will happen when the plugin is passed an object as an
29 // argument from the host (renderer) as an input argument to a sync function, 30 // argument from the host (renderer) as an input argument to a sync function,
30 // but where ownership is not passed. 31 // but where ownership is not passed.
31 // 32 //
32 // This class maintains the "track_with_no_reference_count" but doesn't do 33 // This class maintains the "track_with_no_reference_count" but doesn't do
33 // anything with it other than call virtual functions. The interesting parts 34 // anything with it other than call virtual functions. The interesting parts
34 // are added by the PluginObjectVar derived from this class. 35 // are added by the PluginObjectVar derived from this class.
35 class PPAPI_SHARED_EXPORT VarTracker 36 class PPAPI_SHARED_EXPORT VarTracker
36 #ifdef ENABLE_PEPPER_THREADING 37 #if 1//def ENABLE_PEPPER_THREADING
viettrungluu 2012/06/15 21:55:52 wtf?
37 : NON_EXPORTED_BASE(public base::NonThreadSafeDoNothing) { 38 : NON_EXPORTED_BASE(public base::NonThreadSafeDoNothing) {
38 #else 39 #else
39 // TODO(dmichael): Remove the thread checking when calls are allowed off the 40 // TODO(dmichael): Remove the thread checking when calls are allowed off the
40 // main thread (crbug.com/92909). 41 // main thread (crbug.com/92909).
41 : NON_EXPORTED_BASE(public base::NonThreadSafe) { 42 : NON_EXPORTED_BASE(public base::NonThreadSafe) {
42 #endif 43 #endif
43 public: 44 public:
44 VarTracker(); 45 VarTracker();
45 virtual ~VarTracker(); 46 virtual ~VarTracker();
46 47
(...skipping 30 matching lines...) Expand all
77 // used in production code. The PP_Vars are returned in no particular order, 78 // used in production code. The PP_Vars are returned in no particular order,
78 // and their reference counts are unaffected. 79 // and their reference counts are unaffected.
79 std::vector<PP_Var> GetLiveVars(); 80 std::vector<PP_Var> GetLiveVars();
80 81
81 // Retrieves the internal reference counts for testing. Returns 0 if we 82 // Retrieves the internal reference counts for testing. Returns 0 if we
82 // know about the object but the corresponding value is 0, or -1 if the 83 // know about the object but the corresponding value is 0, or -1 if the
83 // given object ID isn't in our map. 84 // given object ID isn't in our map.
84 int GetRefCountForObject(const PP_Var& object); 85 int GetRefCountForObject(const PP_Var& object);
85 int GetTrackedWithNoReferenceCountForObject(const PP_Var& object); 86 int GetTrackedWithNoReferenceCountForObject(const PP_Var& object);
86 87
88 // Called after an instance is deleted to do var cleanup.
89 virtual void DidDeleteInstance(PP_Instance instance) = 0;
90
87 protected: 91 protected:
88 struct VarInfo { 92 struct VarInfo {
89 VarInfo(); 93 VarInfo();
90 VarInfo(Var* v, int input_ref_count); 94 VarInfo(Var* v, int input_ref_count);
91 95
92 scoped_refptr<Var> var; 96 scoped_refptr<Var> var;
93 97
94 // Explicit reference count. This value is affected by the renderer calling 98 // Explicit reference count. This value is affected by the renderer calling
95 // AddRef and Release. A nonzero value here is represented by a single 99 // AddRef and Release. A nonzero value here is represented by a single
96 // reference in the host on our behalf (this reduces IPC traffic). 100 // reference in the host on our behalf (this reduces IPC traffic).
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // implemented by the Host and Plugin tracker separately, so that it can be 165 // implemented by the Host and Plugin tracker separately, so that it can be
162 // a real WebKit ArrayBuffer on the host side. 166 // a real WebKit ArrayBuffer on the host side.
163 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) = 0; 167 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) = 0;
164 168
165 DISALLOW_COPY_AND_ASSIGN(VarTracker); 169 DISALLOW_COPY_AND_ASSIGN(VarTracker);
166 }; 170 };
167 171
168 } // namespace ppapi 172 } // namespace ppapi
169 173
170 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ 174 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_
OLDNEW
« ppapi/proxy/ppp_class_proxy.cc ('K') | « ppapi/shared_impl/test_globals.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698