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

Side by Side Diff: test/cctest/test-api.cc

Issue 1074153002: simplify GlobalValueMap calls to DisposeWeak (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « include/v8-util.h ('k') | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3335 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 static K KeyFromWeakCallbackInfo( 3346 static K KeyFromWeakCallbackInfo(
3347 const v8::WeakCallbackInfo<WeakCallbackDataType>& data) { 3347 const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {
3348 return data.GetParameter()->key; 3348 return data.GetParameter()->key;
3349 } 3349 }
3350 static void DisposeCallbackData(WeakCallbackDataType* data) { delete data; } 3350 static void DisposeCallbackData(WeakCallbackDataType* data) { delete data; }
3351 static void Dispose(v8::Isolate* isolate, v8::Global<V> value, K key) { 3351 static void Dispose(v8::Isolate* isolate, v8::Global<V> value, K key) {
3352 CHECK_EQ(IntKeyToVoidPointer(key), 3352 CHECK_EQ(IntKeyToVoidPointer(key),
3353 v8::Object::GetAlignedPointerFromInternalField(value, 0)); 3353 v8::Object::GetAlignedPointerFromInternalField(value, 0));
3354 } 3354 }
3355 static void DisposeWeak( 3355 static void DisposeWeak(
3356 v8::Isolate* isolate, 3356 const v8::WeakCallbackInfo<WeakCallbackDataType>& info) {
3357 const v8::WeakCallbackInfo<WeakCallbackDataType>& info, K key) { 3357 K key = KeyFromWeakCallbackInfo(info);
3358 CHECK_EQ(IntKeyToVoidPointer(key), info.GetInternalField(0)); 3358 CHECK_EQ(IntKeyToVoidPointer(key), info.GetInternalField(0));
3359 DisposeCallbackData(info.GetParameter()); 3359 DisposeCallbackData(info.GetParameter());
3360 } 3360 }
3361 }; 3361 };
3362 3362
3363 } // namespace 3363 } // namespace
3364 3364
3365 3365
3366 TEST(GlobalValueMap) { 3366 TEST(GlobalValueMap) {
3367 typedef v8::GlobalValueMap<int, v8::Object, 3367 typedef v8::GlobalValueMap<int, v8::Object,
(...skipping 18525 matching lines...) Expand 10 before | Expand all | Expand 10 after
21893 } 21893 }
21894 { 21894 {
21895 v8::TryCatch try_catch; 21895 v8::TryCatch try_catch;
21896 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); 21896 uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
21897 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, 21897 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString,
21898 length).IsEmpty()); 21898 length).IsEmpty());
21899 CHECK(!try_catch.HasCaught()); 21899 CHECK(!try_catch.HasCaught());
21900 } 21900 }
21901 free(buffer); 21901 free(buffer);
21902 } 21902 }
OLDNEW
« no previous file with comments | « include/v8-util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698