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

Unified Diff: test/cctest/test-api.cc

Issue 2658008: Remove the SetExternalStringDiposeCallback API... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc (revision 4813)
+++ test/cctest/test-api.cc (working copy)
@@ -612,30 +612,33 @@
}
-static int dispose_count = 0;
-static void DisposeExternalStringCount(
- String::ExternalStringResourceBase* resource) {
- dispose_count++;
-}
+class TestAsciiResourceWithDisposeControl: public TestAsciiResource {
+ public:
+ static int dispose_calls;
+ TestAsciiResourceWithDisposeControl(const char* data, bool dispose)
+ : TestAsciiResource(data),
+ dispose_(dispose) { }
-static void DisposeExternalStringDeleteAndCount(
- String::ExternalStringResourceBase* resource) {
- delete resource;
- dispose_count++;
-}
+ void Dispose() {
+ ++dispose_calls;
+ if (dispose_) delete this;
+ }
+ private:
+ bool dispose_;
+};
-TEST(ExternalStringWithResourceDisposeCallback) {
+int TestAsciiResourceWithDisposeControl::dispose_calls = 0;
+
+
+TEST(ExternalStringWithDisposeHandling) {
const char* c_source = "1 + 2 * 3";
- // Set an external string collected callback which does not delete the object.
- v8::V8::SetExternalStringDiposeCallback(DisposeExternalStringCount);
-
// Use a stack allocated external string resource allocated object.
- dispose_count = 0;
TestAsciiResource::dispose_count = 0;
- TestAsciiResource res_stack(i::StrDup(c_source));
+ TestAsciiResourceWithDisposeControl::dispose_calls = 0;
+ TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false);
{
v8::HandleScope scope;
LocalContext env;
@@ -649,16 +652,14 @@
}
v8::internal::CompilationCache::Clear();
v8::internal::Heap::CollectAllGarbage(false);
- CHECK_EQ(1, dispose_count);
+ CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
CHECK_EQ(0, TestAsciiResource::dispose_count);
- // Set an external string collected callback which does delete the object.
- v8::V8::SetExternalStringDiposeCallback(DisposeExternalStringDeleteAndCount);
-
// Use a heap allocated external string resource allocated object.
- dispose_count = 0;
TestAsciiResource::dispose_count = 0;
- TestAsciiResource* res_heap = new TestAsciiResource(i::StrDup(c_source));
+ TestAsciiResourceWithDisposeControl::dispose_calls = 0;
+ TestAsciiResource* res_heap =
+ new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true);
{
v8::HandleScope scope;
LocalContext env;
@@ -672,7 +673,7 @@
}
v8::internal::CompilationCache::Clear();
v8::internal::Heap::CollectAllGarbage(false);
- CHECK_EQ(1, dispose_count);
+ CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
CHECK_EQ(1, TestAsciiResource::dispose_count);
}
« no previous file with comments | « src/heap-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698