Chromium Code Reviews| Index: include/v8.h |
| diff --git a/include/v8.h b/include/v8.h |
| index 214bf9f2f73774389aed83f1135713556dbbb1cb..143727fe36e5a2cf23d1f1245f7055d9c2b96e8e 100644 |
| --- a/include/v8.h |
| +++ b/include/v8.h |
| @@ -1097,25 +1097,43 @@ class V8_EXPORT ScriptCompiler { |
| * UnboundScript. |
| */ |
| struct V8_EXPORT CachedData { |
| - CachedData() : data(NULL), length(0) {} |
| + CachedData() : data(NULL), length(0), owns_buffer(false) {} |
| // Caller keeps the ownership of data and guarantees that the data stays |
| // alive long enough. |
| - CachedData(const uint8_t* data, int length) : data(data), length(length) {} |
| + CachedData(const uint8_t* data, int length, bool owns_buffer = false); |
|
dcarney
2014/03/18 14:34:44
make enum
marja
2014/03/18 16:11:05
Done.
|
| + ~CachedData(); |
| // TODO(marja): Async compilation; add constructors which take a callback |
| // which will be called when V8 no longer needs the data. |
| const uint8_t* data; |
| int length; |
| + bool owns_buffer; |
| + |
| + private: |
| + // Prevent copying. Not implemented. |
| + CachedData(const CachedData&); |
| }; |
| /** |
| * Source code which can be then compiled to a UnboundScript or |
| * BoundScript. |
| */ |
| - struct V8_EXPORT Source { |
| + class V8_EXPORT Source { |
| + public: |
| + // Source takes ownership of CachedData. |
| Source(Local<String> source_string, const ScriptOrigin& origin, |
| - const CachedData& cached_data = CachedData()); |
| - Source(Local<String> source_string, |
| - const CachedData& cached_data = CachedData()); |
| + CachedData* cached_data = NULL); |
| + Source(Local<String> source_string, CachedData* cached_data = NULL); |
| + ~Source(); |
| + |
| + // Ownership of the CachedData or its buffers is *not* transferred to the |
| + // caller. The CachedData object is alive as long as the Source object is |
| + // alive. |
| + const CachedData* GetCachedData() const; |
| + |
| + private: |
| + friend class ScriptCompiler; |
| + // Prevent copying. Not implemented. |
| + Source(const Source&); |
| Local<String> source_string; |
| @@ -1125,8 +1143,10 @@ class V8_EXPORT ScriptCompiler { |
| Handle<Integer> resource_column_offset; |
| Handle<Boolean> resource_is_shared_cross_origin; |
| - // Cached data from previous compilation (if any). |
| - CachedData cached_data; |
| + // Cached data from previous compilation (if any), or generated during |
| + // compilation (if the generate_cached_data flag is passed to |
| + // ScriptCompiler). |
| + CachedData* cached_data; |
| }; |
| enum CompileOptions { |
| @@ -1142,7 +1162,7 @@ class V8_EXPORT ScriptCompiler { |
| * bound to a context). |
| */ |
| static Local<UnboundScript> CompileUnbound( |
| - Isolate* isolate, const Source& source, |
| + Isolate* isolate, Source* source, |
| CompileOptions options = kNoCompileOptions); |
| /** |
| @@ -1157,7 +1177,7 @@ class V8_EXPORT ScriptCompiler { |
| * context. |
| */ |
| static Local<Script> Compile( |
| - Isolate* isolate, const Source& source, |
| + Isolate* isolate, Source* source, |
| CompileOptions options = kNoCompileOptions); |
| }; |