| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "content/renderer/pepper/host_globals.h" | 6 #include "content/renderer/pepper/host_globals.h" |
| 7 #include "content/renderer/pepper/host_var_tracker.h" | 7 #include "content/renderer/pepper/host_var_tracker.h" |
| 8 #include "content/renderer/pepper/mock_resource.h" | 8 #include "content/renderer/pepper/mock_resource.h" |
| 9 #include "content/renderer/pepper/npapi_glue.h" | 9 #include "content/renderer/pepper/npapi_glue.h" |
| 10 #include "content/renderer/pepper/npobject_var.h" | 10 #include "content/renderer/pepper/npobject_var.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 object->_class = &g_tracked_npclass; | 52 object->_class = &g_tracked_npclass; |
| 53 object->referenceCount = 1; | 53 object->referenceCount = 1; |
| 54 | 54 |
| 55 g_npobjects_alive++; | 55 g_npobjects_alive++; |
| 56 return object; | 56 return object; |
| 57 } | 57 } |
| 58 | 58 |
| 59 class ReleaseNPObject { | 59 class ReleaseNPObject { |
| 60 public: | 60 public: |
| 61 void operator()(NPObject* o) const { | 61 void operator()(NPObject* o) const { |
| 62 WebKit::WebBindings::releaseObject(o); | 62 blink::WebBindings::releaseObject(o); |
| 63 } | 63 } |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 // Handles automatically releasing a reference to the NPObject on destruction. | 66 // Handles automatically releasing a reference to the NPObject on destruction. |
| 67 // It's assumed the input has a ref already taken. | 67 // It's assumed the input has a ref already taken. |
| 68 typedef scoped_ptr_malloc<NPObject, ReleaseNPObject> NPObjectReleaser; | 68 typedef scoped_ptr_malloc<NPObject, ReleaseNPObject> NPObjectReleaser; |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 class HostVarTrackerTest : public PpapiUnittest { | 72 class HostVarTrackerTest : public PpapiUnittest { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 var_tracker->ReleaseVar(static_cast<int32_t>(pp_object1.value.as_id)); | 125 var_tracker->ReleaseVar(static_cast<int32_t>(pp_object1.value.as_id)); |
| 126 | 126 |
| 127 // Releasing the resource should free the internal ref, and so making a new | 127 // Releasing the resource should free the internal ref, and so making a new |
| 128 // one now should generate a new ID. | 128 // one now should generate a new ID. |
| 129 PP_Var pp_object3 = NPObjectToPPVarForTest(instance(), npobject.get()); | 129 PP_Var pp_object3 = NPObjectToPPVarForTest(instance(), npobject.get()); |
| 130 EXPECT_NE(pp_object1.value.as_id, pp_object3.value.as_id); | 130 EXPECT_NE(pp_object1.value.as_id, pp_object3.value.as_id); |
| 131 var_tracker->ReleaseVar(static_cast<int32_t>(pp_object3.value.as_id)); | 131 var_tracker->ReleaseVar(static_cast<int32_t>(pp_object3.value.as_id)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace content | 134 } // namespace content |
| OLD | NEW |