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

Side by Side Diff: include/v8-util.h

Issue 297193004: Fix the "PersistentValueMap" memory leak reported here: (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project 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 V8_UTIL_H_ 5 #ifndef V8_UTIL_H_
6 #define V8_UTIL_H_ 6 #define V8_UTIL_H_
7 7
8 #include "v8.h" 8 #include "v8.h"
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 293 }
294 294
295 static void WeakCallback( 295 static void WeakCallback(
296 const WeakCallbackData<V, typename Traits::WeakCallbackDataType>& data) { 296 const WeakCallbackData<V, typename Traits::WeakCallbackDataType>& data) {
297 if (Traits::kCallbackType != kNotWeak) { 297 if (Traits::kCallbackType != kNotWeak) {
298 PersistentValueMap<K, V, Traits>* persistentValueMap = 298 PersistentValueMap<K, V, Traits>* persistentValueMap =
299 Traits::MapFromWeakCallbackData(data); 299 Traits::MapFromWeakCallbackData(data);
300 K key = Traits::KeyFromWeakCallbackData(data); 300 K key = Traits::KeyFromWeakCallbackData(data);
301 Traits::Dispose(data.GetIsolate(), 301 Traits::Dispose(data.GetIsolate(),
302 persistentValueMap->Remove(key).Pass(), key); 302 persistentValueMap->Remove(key).Pass(), key);
303 Traits::DisposeCallbackData(data.GetParameter());
303 } 304 }
304 } 305 }
305 306
306 static V* FromVal(PersistentContainerValue v) { 307 static V* FromVal(PersistentContainerValue v) {
307 return reinterpret_cast<V*>(v); 308 return reinterpret_cast<V*>(v);
308 } 309 }
309 310
310 static bool SetReturnValueFromVal( 311 static bool SetReturnValueFromVal(
311 ReturnValue<Value>& returnValue, PersistentContainerValue value) { 312 ReturnValue<Value>& returnValue, PersistentContainerValue value) {
312 bool hasValue = value != kPersistentContainerNotFound; 313 bool hasValue = value != kPersistentContainerNotFound;
(...skipping 17 matching lines...) Expand all
330 } 331 }
331 332
332 /** 333 /**
333 * Return a container value as UniquePersistent and make sure the weak 334 * Return a container value as UniquePersistent and make sure the weak
334 * callback is properly disposed of. All remove functionality should go 335 * callback is properly disposed of. All remove functionality should go
335 * through this. 336 * through this.
336 */ 337 */
337 static UniquePersistent<V> Release(PersistentContainerValue v) { 338 static UniquePersistent<V> Release(PersistentContainerValue v) {
338 UniquePersistent<V> p; 339 UniquePersistent<V> p;
339 p.val_ = FromVal(v); 340 p.val_ = FromVal(v);
340 if (Traits::kCallbackType != kNotWeak && !p.IsEmpty()) { 341 if (Traits::kCallbackType != kNotWeak && p.IsWeak()) {
341 Traits::DisposeCallbackData( 342 Traits::DisposeCallbackData(
342 p.template ClearWeak<typename Traits::WeakCallbackDataType>()); 343 p.template ClearWeak<typename Traits::WeakCallbackDataType>());
343 } 344 }
344 return p.Pass(); 345 return p.Pass();
345 } 346 }
346 347
347 Isolate* isolate_; 348 Isolate* isolate_;
348 typename Traits::Impl impl_; 349 typename Traits::Impl impl_;
349 }; 350 };
350 351
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 return reinterpret_cast<V*>(v); 478 return reinterpret_cast<V*>(v);
478 } 479 }
479 480
480 Isolate* isolate_; 481 Isolate* isolate_;
481 typename Traits::Impl impl_; 482 typename Traits::Impl impl_;
482 }; 483 };
483 484
484 } // namespace v8 485 } // namespace v8
485 486
486 #endif // V8_UTIL_H_ 487 #endif // V8_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698