OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 V8ValueHolder(v8::Isolate* isolate, v8::Persistent<T> value) | 44 V8ValueHolder(v8::Isolate* isolate, v8::Persistent<T> value) |
45 { | 45 { |
46 reset(isolate, value); | 46 reset(isolate, value); |
47 } | 47 } |
48 V8ValueHolder(v8::Isolate* isolate, v8::Handle<T> value) | 48 V8ValueHolder(v8::Isolate* isolate, v8::Handle<T> value) |
49 { | 49 { |
50 reset(isolate, value); | 50 reset(isolate, value); |
51 } | 51 } |
52 ~V8ValueHolder() | 52 ~V8ValueHolder() |
53 { | 53 { |
54 if (this->value.get()) | 54 reset(isolate, v8::Persistent<T>()); |
55 { | |
56 this->value->Dispose(this->isolate); | |
57 this->value.reset(0); | |
58 } | |
59 } | 55 } |
60 void reset(v8::Isolate* isolate, v8::Persistent<T> value) | 56 void reset(v8::Isolate* isolate, v8::Persistent<T> value) |
61 { | 57 { |
62 if (this->value.get()) | 58 if (this->value.get()) |
63 { | 59 { |
64 this->value->Dispose(this->isolate); | 60 this->value->Dispose(this->isolate); |
65 this->value.reset(0); | 61 this->value.reset(0); |
66 } | 62 } |
67 | 63 |
68 if (!value.IsEmpty()) | 64 if (!value.IsEmpty()) |
(...skipping 20 matching lines...) Expand all Loading... |
89 { | 85 { |
90 return *value; | 86 return *value; |
91 } | 87 } |
92 private: | 88 private: |
93 v8::Isolate* isolate; | 89 v8::Isolate* isolate; |
94 std::auto_ptr<v8::Persistent<T> > value; | 90 std::auto_ptr<v8::Persistent<T> > value; |
95 }; | 91 }; |
96 } | 92 } |
97 | 93 |
98 #endif | 94 #endif |
OLD | NEW |