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

Unified Diff: include/v8.h

Issue 2645004: Add an API to control the disposal of external string resources... (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 | « no previous file | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
===================================================================
--- include/v8.h (revision 4799)
+++ include/v8.h (working copy)
@@ -1122,11 +1122,13 @@
/**
* Creates a new external string using the data defined in the given
- * resource. The resource is deleted when the external string is no
- * longer live on V8's heap. The caller of this function should not
- * delete or modify the resource. Neither should the underlying buffer be
- * deallocated or modified except through the destructor of the
- * external string resource.
+ * resource. When the external string is no longer live on V8's heap the
+ * resource will be disposed. If a disposal callback has been set using
+ * SetExternalStringDiposeCallback this callback will be called to dispose
+ * the resource. Otherwise, V8 will dispose the resource using the C++ delete
+ * operator. The caller of this function should not otherwise delete or
+ * modify the resource. Neither should the underlying buffer be deallocated
+ * or modified except through the destructor of the external string resource.
*/
static Local<String> NewExternal(ExternalStringResource* resource);
@@ -1136,17 +1138,20 @@
* will use the external string resource. The external string resource's
* character contents needs to be equivalent to this string.
* Returns true if the string has been changed to be an external string.
- * The string is not modified if the operation fails.
+ * The string is not modified if the operation fails. See NewExternal for
+ * information on the lifetime of the resource.
*/
bool MakeExternal(ExternalStringResource* resource);
/**
* Creates a new external string using the ascii data defined in the given
- * resource. The resource is deleted when the external string is no
- * longer live on V8's heap. The caller of this function should not
- * delete or modify the resource. Neither should the underlying buffer be
- * deallocated or modified except through the destructor of the
- * external string resource.
+ * resource. When the external string is no longer live on V8's heap the
+ * resource will be disposed. If a disposal callback has been set using
+ * SetExternalStringDiposeCallback this callback will be called to dispose
+ * the resource. Otherwise, V8 will dispose the resource using the C++ delete
+ * operator. The caller of this function should not otherwise delete or
+ * modify the resource. Neither should the underlying buffer be deallocated
+ * or modified except through the destructor of the external string resource.
*/
static Local<String> NewExternal(ExternalAsciiStringResource* resource);
@@ -1156,7 +1161,8 @@
* will use the external string resource. The external string resource's
* character contents needs to be equivalent to this string.
* Returns true if the string has been changed to be an external string.
- * The string is not modified if the operation fails.
+ * The string is not modified if the operation fails. See NewExternal for
+ * information on the lifetime of the resource.
*/
bool MakeExternal(ExternalAsciiStringResource* resource);
@@ -1245,6 +1251,10 @@
};
+typedef void (*ExternalStringDiposeCallback)
+ (String::ExternalStringResourceBase* resource);
+
+
/**
* A JavaScript number value (ECMA-262, 4.3.20)
*/
@@ -2462,6 +2472,15 @@
static void RemoveMessageListeners(MessageCallback that);
/**
+ * Set a callback to be called when an external string is no longer live on
+ * V8's heap. The resource will no longer be needed by V8 and the embedder
+ * can dispose of if. If this callback is not set V8 will free the resource
+ * using the C++ delete operator.
+ */
+ static void SetExternalStringDiposeCallback(
+ ExternalStringDiposeCallback that);
+
+ /**
* Sets V8 flags from a string.
*/
static void SetFlagsFromString(const char* str, int length);
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698