OLD | NEW |
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 #include "ppapi/proxy/plugin_var_tracker.h" | 5 #include "ppapi/proxy/plugin_var_tracker.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "ppapi/c/dev/ppp_class_deprecated.h" | 9 #include "ppapi/c/dev/ppp_class_deprecated.h" |
10 #include "ppapi/c/ppb_var.h" | 10 #include "ppapi/c/ppb_var.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // Actually create the PP_Var, this will add all the tracking info but not | 49 // Actually create the PP_Var, this will add all the tracking info but not |
50 // adjust any refcounts. | 50 // adjust any refcounts. |
51 PP_Var ret = GetOrCreateObjectVarID(object.get()); | 51 PP_Var ret = GetOrCreateObjectVarID(object.get()); |
52 | 52 |
53 VarInfo& info = GetLiveVar(ret)->second; | 53 VarInfo& info = GetLiveVar(ret)->second; |
54 if (info.ref_count > 0) { | 54 if (info.ref_count > 0) { |
55 // We already had a reference to it before. That means the renderer now has | 55 // We already had a reference to it before. That means the renderer now has |
56 // two references on our behalf. We want to transfer that extra reference | 56 // two references on our behalf. We want to transfer that extra reference |
57 // to our list. This means we addref in the plugin, and release the extra | 57 // to our list. This means we addref in the plugin, and release the extra |
58 // one in the renderer. | 58 // one in the renderer. |
59 SendReleaseObjectMsg(*object); | 59 SendReleaseObjectMsg(*object.get()); |
60 } | 60 } |
61 info.ref_count++; | 61 info.ref_count++; |
62 return ret; | 62 return ret; |
63 } | 63 } |
64 | 64 |
65 PP_Var PluginVarTracker::TrackObjectWithNoReference( | 65 PP_Var PluginVarTracker::TrackObjectWithNoReference( |
66 const PP_Var& host_var, | 66 const PP_Var& host_var, |
67 PluginDispatcher* dispatcher) { | 67 PluginDispatcher* dispatcher) { |
68 DCHECK(CalledOnValidThread()); | 68 DCHECK(CalledOnValidThread()); |
69 DCHECK(host_var.type == PP_VARTYPE_OBJECT); | 69 DCHECK(host_var.type == PP_VARTYPE_OBJECT); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 VarMap::iterator ret = live_vars_.find(found->second); | 364 VarMap::iterator ret = live_vars_.find(found->second); |
365 DCHECK(ret != live_vars_.end()); | 365 DCHECK(ret != live_vars_.end()); |
366 | 366 |
367 // All objects should be proxy objects. | 367 // All objects should be proxy objects. |
368 DCHECK(ret->second.var->AsProxyObjectVar()); | 368 DCHECK(ret->second.var->AsProxyObjectVar()); |
369 return scoped_refptr<ProxyObjectVar>(ret->second.var->AsProxyObjectVar()); | 369 return scoped_refptr<ProxyObjectVar>(ret->second.var->AsProxyObjectVar()); |
370 } | 370 } |
371 | 371 |
372 } // namesace proxy | 372 } // namesace proxy |
373 } // namespace ppapi | 373 } // namespace ppapi |
OLD | NEW |