1 // Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
13 // * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 // ---------------------------------------------------------------------------
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
38 #ifndef CEF_INCLUDE_CEF_V8_H_
39 #define CEF_INCLUDE_CEF_V8_H_
42 #include "include/cef_base.h"
43 #include "include/cef_browser.h"
44 #include "include/cef_frame.h"
45 #include "include/cef_task.h"
50 class CefV8StackFrame;
55 // Register a new V8 extension with the specified JavaScript extension code and
56 // handler. Functions implemented by the handler are prototyped using the
57 // keyword 'native'. The calling of a native function is restricted to the scope
58 // in which the prototype of the native function is defined. This function may
59 // only be called on the render process main thread.
61 // Example JavaScript extension code:
63 // // create the 'example' global object if it doesn't already exist.
66 // // create the 'example.test' global object if it doesn't already exist.
70 // // Define the function 'example.test.myfunction'.
71 // example.test.myfunction = function() {
72 // // Call CefV8Handler::Execute() with the function name 'MyFunction'
73 // // and no arguments.
74 // native function MyFunction();
75 // return MyFunction();
77 // // Define the getter function for parameter 'example.test.myparam'.
78 // example.test.__defineGetter__('myparam', function() {
79 // // Call CefV8Handler::Execute() with the function name 'GetMyParam'
80 // // and no arguments.
81 // native function GetMyParam();
82 // return GetMyParam();
84 // // Define the setter function for parameter 'example.test.myparam'.
85 // example.test.__defineSetter__('myparam', function(b) {
86 // // Call CefV8Handler::Execute() with the function name 'SetMyParam'
87 // // and a single argument.
88 // native function SetMyParam();
89 // if(b) SetMyParam(b);
92 // // Extension definitions can also contain normal JavaScript variables
95 // example.test.increment = function() {
101 // Example usage in the page:
103 // // Call the function.
104 // example.test.myfunction();
105 // // Set the parameter.
106 // example.test.myparam = value;
107 // // Get the parameter.
108 // value = example.test.myparam;
109 // // Call another function.
110 // example.test.increment();
113 /*--cef(optional_param=handler)--*/
114 bool CefRegisterExtension(const CefString& extension_name,
115 const CefString& javascript_code,
116 CefRefPtr<CefV8Handler> handler);
120 // Class representing a V8 context handle. V8 handles can only be accessed from
121 // the thread on which they are created. Valid threads for creating a V8 handle
122 // include the render process main thread (TID_RENDERER) and WebWorker threads.
123 // A task runner for posting tasks on the associated thread can be retrieved via
124 // the CefV8Context::GetTaskRunner() method.
126 /*--cef(source=library)--*/
127 class CefV8Context : public virtual CefBaseRefCounted {
130 // Returns the current (top) context object in the V8 context stack.
133 static CefRefPtr<CefV8Context> GetCurrentContext();
136 // Returns the entered (bottom) context object in the V8 context stack.
139 static CefRefPtr<CefV8Context> GetEnteredContext();
142 // Returns true if V8 is currently inside a context.
145 static bool InContext();
148 // Returns the task runner associated with this context. V8 handles can only
149 // be accessed from the thread on which they are created. This method can be
150 // called on any render process thread.
153 virtual CefRefPtr<CefTaskRunner> GetTaskRunner() =0;
156 // Returns true if the underlying handle is valid and it can be accessed on
157 // the current thread. Do not call any other methods if this method returns
161 virtual bool IsValid() =0;
164 // Returns the browser for this context. This method will return an empty
165 // reference for WebWorker contexts.
168 virtual CefRefPtr<CefBrowser> GetBrowser() =0;
171 // Returns the frame for this context. This method will return an empty
172 // reference for WebWorker contexts.
175 virtual CefRefPtr<CefFrame> GetFrame() =0;
178 // Returns the global object for this context. The context must be entered
179 // before calling this method.
182 virtual CefRefPtr<CefV8Value> GetGlobal() =0;
185 // Enter this context. A context must be explicitly entered before creating a
186 // V8 Object, Array, Function or Date asynchronously. Exit() must be called
187 // the same number of times as Enter() before releasing this context. V8
188 // objects belong to the context in which they are created. Returns true if
189 // the scope was entered successfully.
192 virtual bool Enter() =0;
195 // Exit this context. Call this method only after calling Enter(). Returns
196 // true if the scope was exited successfully.
199 virtual bool Exit() =0;
202 // Returns true if this object is pointing to the same handle as |that|
206 virtual bool IsSame(CefRefPtr<CefV8Context> that) =0;
209 // Execute a string of JavaScript code in this V8 context. The |script_url|
210 // parameter is the URL where the script in question can be found, if any.
211 // The |start_line| parameter is the base line number to use for error
212 // reporting. On success |retval| will be set to the return value, if any, and
213 // the function will return true. On failure |exception| will be set to the
214 // exception, if any, and the function will return false.
216 /*--cef(optional_param=script_url)--*/
217 virtual bool Eval(const CefString& code,
218 const CefString& script_url,
220 CefRefPtr<CefV8Value>& retval,
221 CefRefPtr<CefV8Exception>& exception) =0;
225 typedef std::vector<CefRefPtr<CefV8Value> > CefV8ValueList;
228 // Interface that should be implemented to handle V8 function calls. The methods
229 // of this class will be called on the thread associated with the V8 function.
231 /*--cef(source=client)--*/
232 class CefV8Handler : public virtual CefBaseRefCounted {
235 // Handle execution of the function identified by |name|. |object| is the
236 // receiver ('this' object) of the function. |arguments| is the list of
237 // arguments passed to the function. If execution succeeds set |retval| to the
238 // function return value. If execution fails set |exception| to the exception
239 // that will be thrown. Return true if execution was handled.
242 virtual bool Execute(const CefString& name,
243 CefRefPtr<CefV8Value> object,
244 const CefV8ValueList& arguments,
245 CefRefPtr<CefV8Value>& retval,
246 CefString& exception) =0;
250 // Interface that should be implemented to handle V8 accessor calls. Accessor
251 // identifiers are registered by calling CefV8Value::SetValue(). The methods
252 // of this class will be called on the thread associated with the V8 accessor.
254 /*--cef(source=client)--*/
255 class CefV8Accessor : public virtual CefBaseRefCounted {
258 // Handle retrieval the accessor value identified by |name|. |object| is the
259 // receiver ('this' object) of the accessor. If retrieval succeeds set
260 // |retval| to the return value. If retrieval fails set |exception| to the
261 // exception that will be thrown. Return true if accessor retrieval was
265 virtual bool Get(const CefString& name,
266 const CefRefPtr<CefV8Value> object,
267 CefRefPtr<CefV8Value>& retval,
268 CefString& exception) =0;
271 // Handle assignment of the accessor value identified by |name|. |object| is
272 // the receiver ('this' object) of the accessor. |value| is the new value
273 // being assigned to the accessor. If assignment fails set |exception| to the
274 // exception that will be thrown. Return true if accessor assignment was
278 virtual bool Set(const CefString& name,
279 const CefRefPtr<CefV8Value> object,
280 const CefRefPtr<CefV8Value> value,
281 CefString& exception) =0;
285 // Interface that should be implemented to handle V8 interceptor calls. The
286 // methods of this class will be called on the thread associated with the V8
287 // interceptor. Interceptor's named property handlers (with first argument of
288 // type CefString) are called when object is indexed by string. Indexed property
289 // handlers (with first argument of type int) are called when object is indexed
292 /*--cef(source=client)--*/
293 class CefV8Interceptor : public virtual CefBaseRefCounted {
296 // Handle retrieval of the interceptor value identified by |name|. |object| is
297 // the receiver ('this' object) of the interceptor. If retrieval succeeds, set
298 // |retval| to the return value. If the requested value does not exist, don't
299 // set either |retval| or |exception|. If retrieval fails, set |exception| to
300 // the exception that will be thrown. If the property has an associated
301 // accessor, it will be called only if you don't set |retval|.
302 // Return true if interceptor retrieval was handled, false otherwise.
304 /*--cef(capi_name=get_byname)--*/
305 virtual bool Get(const CefString& name,
306 const CefRefPtr<CefV8Value> object,
307 CefRefPtr<CefV8Value>& retval,
308 CefString& exception) =0;
311 // Handle retrieval of the interceptor value identified by |index|. |object|
312 // is the receiver ('this' object) of the interceptor. If retrieval succeeds,
313 // set |retval| to the return value. If the requested value does not exist,
314 // don't set either |retval| or |exception|. If retrieval fails, set
315 // |exception| to the exception that will be thrown.
316 // Return true if interceptor retrieval was handled, false otherwise.
318 /*--cef(capi_name=get_byindex,index_param=index)--*/
319 virtual bool Get(int index,
320 const CefRefPtr<CefV8Value> object,
321 CefRefPtr<CefV8Value>& retval,
322 CefString& exception) =0;
325 // Handle assignment of the interceptor value identified by |name|. |object|
326 // is the receiver ('this' object) of the interceptor. |value| is the new
327 // value being assigned to the interceptor. If assignment fails, set
328 // |exception| to the exception that will be thrown. This setter will always
329 // be called, even when the property has an associated accessor.
330 // Return true if interceptor assignment was handled, false otherwise.
332 /*--cef(capi_name=set_byname)--*/
333 virtual bool Set(const CefString& name,
334 const CefRefPtr<CefV8Value> object,
335 const CefRefPtr<CefV8Value> value,
336 CefString& exception) =0;
339 // Handle assignment of the interceptor value identified by |index|. |object|
340 // is the receiver ('this' object) of the interceptor. |value| is the new
341 // value being assigned to the interceptor. If assignment fails, set
342 // |exception| to the exception that will be thrown.
343 // Return true if interceptor assignment was handled, false otherwise.
345 /*--cef(capi_name=set_byindex,index_param=index)--*/
346 virtual bool Set(int index,
347 const CefRefPtr<CefV8Value> object,
348 const CefRefPtr<CefV8Value> value,
349 CefString& exception) =0;
353 // Class representing a V8 exception. The methods of this class may be called on
354 // any render process thread.
356 /*--cef(source=library)--*/
357 class CefV8Exception : public virtual CefBaseRefCounted {
360 // Returns the exception message.
363 virtual CefString GetMessage() =0;
366 // Returns the line of source code that the exception occurred within.
369 virtual CefString GetSourceLine() =0;
372 // Returns the resource name for the script from where the function causing
373 // the error originates.
376 virtual CefString GetScriptResourceName() =0;
379 // Returns the 1-based number of the line where the error occurred or 0 if the
380 // line number is unknown.
383 virtual int GetLineNumber() =0;
386 // Returns the index within the script of the first character where the error
390 virtual int GetStartPosition() =0;
393 // Returns the index within the script of the last character where the error
397 virtual int GetEndPosition() =0;
400 // Returns the index within the line of the first character where the error
404 virtual int GetStartColumn() =0;
407 // Returns the index within the line of the last character where the error
411 virtual int GetEndColumn() =0;
415 // Class representing a V8 value handle. V8 handles can only be accessed from
416 // the thread on which they are created. Valid threads for creating a V8 handle
417 // include the render process main thread (TID_RENDERER) and WebWorker threads.
418 // A task runner for posting tasks on the associated thread can be retrieved via
419 // the CefV8Context::GetTaskRunner() method.
421 /*--cef(source=library)--*/
422 class CefV8Value : public virtual CefBaseRefCounted {
424 typedef cef_v8_accesscontrol_t AccessControl;
425 typedef cef_v8_propertyattribute_t PropertyAttribute;
428 // Create a new CefV8Value object of type undefined.
431 static CefRefPtr<CefV8Value> CreateUndefined();
434 // Create a new CefV8Value object of type null.
437 static CefRefPtr<CefV8Value> CreateNull();
440 // Create a new CefV8Value object of type bool.
443 static CefRefPtr<CefV8Value> CreateBool(bool value);
446 // Create a new CefV8Value object of type int.
449 static CefRefPtr<CefV8Value> CreateInt(int32 value);
452 // Create a new CefV8Value object of type unsigned int.
455 static CefRefPtr<CefV8Value> CreateUInt(uint32 value);
458 // Create a new CefV8Value object of type double.
461 static CefRefPtr<CefV8Value> CreateDouble(double value);
464 // Create a new CefV8Value object of type Date. This method should only be
465 // called from within the scope of a CefRenderProcessHandler, CefV8Handler or
466 // CefV8Accessor callback, or in combination with calling Enter() and Exit()
467 // on a stored CefV8Context reference.
470 static CefRefPtr<CefV8Value> CreateDate(const CefTime& date);
473 // Create a new CefV8Value object of type string.
475 /*--cef(optional_param=value)--*/
476 static CefRefPtr<CefV8Value> CreateString(const CefString& value);
479 // Create a new CefV8Value object of type object with optional accessor and/or
480 // interceptor. This method should only be called from within the scope of a
481 // CefRenderProcessHandler, CefV8Handler or CefV8Accessor callback, or in
482 // combination with calling Enter() and Exit() on a stored CefV8Context
485 /*--cef(optional_param=accessor, optional_param=interceptor)--*/
486 static CefRefPtr<CefV8Value> CreateObject(
487 CefRefPtr<CefV8Accessor> accessor,
488 CefRefPtr<CefV8Interceptor> interceptor);
491 // Create a new CefV8Value object of type array with the specified |length|.
492 // If |length| is negative the returned array will have length 0. This method
493 // should only be called from within the scope of a CefRenderProcessHandler,
494 // CefV8Handler or CefV8Accessor callback, or in combination with calling
495 // Enter() and Exit() on a stored CefV8Context reference.
498 static CefRefPtr<CefV8Value> CreateArray(int length);
501 // Create a new CefV8Value object of type function. This method should only be
502 // called from within the scope of a CefRenderProcessHandler, CefV8Handler or
503 // CefV8Accessor callback, or in combination with calling Enter() and Exit()
504 // on a stored CefV8Context reference.
507 static CefRefPtr<CefV8Value> CreateFunction(const CefString& name,
508 CefRefPtr<CefV8Handler> handler);
511 // Returns true if the underlying handle is valid and it can be accessed on
512 // the current thread. Do not call any other methods if this method returns
516 virtual bool IsValid() =0;
519 // True if the value type is undefined.
522 virtual bool IsUndefined() =0;
525 // True if the value type is null.
528 virtual bool IsNull() =0;
531 // True if the value type is bool.
534 virtual bool IsBool() =0;
537 // True if the value type is int.
540 virtual bool IsInt() =0;
543 // True if the value type is unsigned int.
546 virtual bool IsUInt() =0;
549 // True if the value type is double.
552 virtual bool IsDouble() =0;
555 // True if the value type is Date.
558 virtual bool IsDate() =0;
561 // True if the value type is string.
564 virtual bool IsString() =0;
567 // True if the value type is object.
570 virtual bool IsObject() =0;
573 // True if the value type is array.
576 virtual bool IsArray() =0;
579 // True if the value type is function.
582 virtual bool IsFunction() =0;
585 // Returns true if this object is pointing to the same handle as |that|
589 virtual bool IsSame(CefRefPtr<CefV8Value> that) =0;
592 // Return a bool value.
595 virtual bool GetBoolValue() =0;
598 // Return an int value.
601 virtual int32 GetIntValue() =0;
604 // Return an unsigned int value.
607 virtual uint32 GetUIntValue() =0;
610 // Return a double value.
613 virtual double GetDoubleValue() =0;
616 // Return a Date value.
619 virtual CefTime GetDateValue() =0;
622 // Return a string value.
625 virtual CefString GetStringValue() =0;
628 // OBJECT METHODS - These methods are only available on objects. Arrays and
629 // functions are also objects. String- and integer-based keys can be used
630 // interchangably with the framework converting between them as necessary.
633 // Returns true if this is a user created object.
636 virtual bool IsUserCreated() =0;
639 // Returns true if the last method call resulted in an exception. This
640 // attribute exists only in the scope of the current CEF value object.
643 virtual bool HasException() =0;
646 // Returns the exception resulting from the last method call. This attribute
647 // exists only in the scope of the current CEF value object.
650 virtual CefRefPtr<CefV8Exception> GetException() =0;
653 // Clears the last exception and returns true on success.
656 virtual bool ClearException() =0;
659 // Returns true if this object will re-throw future exceptions. This attribute
660 // exists only in the scope of the current CEF value object.
663 virtual bool WillRethrowExceptions() =0;
666 // Set whether this object will re-throw future exceptions. By default
667 // exceptions are not re-thrown. If a exception is re-thrown the current
668 // context should not be accessed again until after the exception has been
669 // caught and not re-thrown. Returns true on success. This attribute exists
670 // only in the scope of the current CEF value object.
673 virtual bool SetRethrowExceptions(bool rethrow) =0;
676 // Returns true if the object has a value with the specified identifier.
678 /*--cef(capi_name=has_value_bykey,optional_param=key)--*/
679 virtual bool HasValue(const CefString& key) =0;
682 // Returns true if the object has a value with the specified identifier.
684 /*--cef(capi_name=has_value_byindex,index_param=index)--*/
685 virtual bool HasValue(int index) =0;
688 // Deletes the value with the specified identifier and returns true on
689 // success. Returns false if this method is called incorrectly or an exception
690 // is thrown. For read-only and don't-delete values this method will return
691 // true even though deletion failed.
693 /*--cef(capi_name=delete_value_bykey,optional_param=key)--*/
694 virtual bool DeleteValue(const CefString& key) =0;
697 // Deletes the value with the specified identifier and returns true on
698 // success. Returns false if this method is called incorrectly, deletion fails
699 // or an exception is thrown. For read-only and don't-delete values this
700 // method will return true even though deletion failed.
702 /*--cef(capi_name=delete_value_byindex,index_param=index)--*/
703 virtual bool DeleteValue(int index) =0;
706 // Returns the value with the specified identifier on success. Returns NULL
707 // if this method is called incorrectly or an exception is thrown.
709 /*--cef(capi_name=get_value_bykey,optional_param=key)--*/
710 virtual CefRefPtr<CefV8Value> GetValue(const CefString& key) =0;
713 // Returns the value with the specified identifier on success. Returns NULL
714 // if this method is called incorrectly or an exception is thrown.
716 /*--cef(capi_name=get_value_byindex,index_param=index)--*/
717 virtual CefRefPtr<CefV8Value> GetValue(int index) =0;
720 // Associates a value with the specified identifier and returns true on
721 // success. Returns false if this method is called incorrectly or an exception
722 // is thrown. For read-only values this method will return true even though
723 // assignment failed.
725 /*--cef(capi_name=set_value_bykey,optional_param=key)--*/
726 virtual bool SetValue(const CefString& key, CefRefPtr<CefV8Value> value,
727 PropertyAttribute attribute) =0;
730 // Associates a value with the specified identifier and returns true on
731 // success. Returns false if this method is called incorrectly or an exception
732 // is thrown. For read-only values this method will return true even though
733 // assignment failed.
735 /*--cef(capi_name=set_value_byindex,index_param=index)--*/
736 virtual bool SetValue(int index, CefRefPtr<CefV8Value> value) =0;
739 // Registers an identifier and returns true on success. Access to the
740 // identifier will be forwarded to the CefV8Accessor instance passed to
741 // CefV8Value::CreateObject(). Returns false if this method is called
742 // incorrectly or an exception is thrown. For read-only values this method
743 // will return true even though assignment failed.
745 /*--cef(capi_name=set_value_byaccessor,optional_param=key)--*/
746 virtual bool SetValue(const CefString& key, AccessControl settings,
747 PropertyAttribute attribute) =0;
750 // Read the keys for the object's values into the specified vector. Integer-
751 // based keys will also be returned as strings.
754 virtual bool GetKeys(std::vector<CefString>& keys) =0;
757 // Sets the user data for this object and returns true on success. Returns
758 // false if this method is called incorrectly. This method can only be called
759 // on user created objects.
761 /*--cef(optional_param=user_data)--*/
762 virtual bool SetUserData(CefRefPtr<CefBaseRefCounted> user_data) =0;
765 // Returns the user data, if any, assigned to this object.
768 virtual CefRefPtr<CefBaseRefCounted> GetUserData() =0;
771 // Returns the amount of externally allocated memory registered for the
775 virtual int GetExternallyAllocatedMemory() =0;
778 // Adjusts the amount of registered external memory for the object. Used to
779 // give V8 an indication of the amount of externally allocated memory that is
780 // kept alive by JavaScript objects. V8 uses this information to decide when
781 // to perform global garbage collection. Each CefV8Value tracks the amount of
782 // external memory associated with it and automatically decreases the global
783 // total by the appropriate amount on its destruction. |change_in_bytes|
784 // specifies the number of bytes to adjust by. This method returns the number
785 // of bytes associated with the object after the adjustment. This method can
786 // only be called on user created objects.
789 virtual int AdjustExternallyAllocatedMemory(int change_in_bytes) =0;
792 // ARRAY METHODS - These methods are only available on arrays.
795 // Returns the number of elements in the array.
798 virtual int GetArrayLength() =0;
801 // FUNCTION METHODS - These methods are only available on functions.
804 // Returns the function name.
807 virtual CefString GetFunctionName() =0;
810 // Returns the function handler or NULL if not a CEF-created function.
813 virtual CefRefPtr<CefV8Handler> GetFunctionHandler() =0;
816 // Execute the function using the current V8 context. This method should only
817 // be called from within the scope of a CefV8Handler or CefV8Accessor
818 // callback, or in combination with calling Enter() and Exit() on a stored
819 // CefV8Context reference. |object| is the receiver ('this' object) of the
820 // function. If |object| is empty the current context's global object will be
821 // used. |arguments| is the list of arguments that will be passed to the
822 // function. Returns the function return value on success. Returns NULL if
823 // this method is called incorrectly or an exception is thrown.
825 /*--cef(optional_param=object)--*/
826 virtual CefRefPtr<CefV8Value> ExecuteFunction(
827 CefRefPtr<CefV8Value> object,
828 const CefV8ValueList& arguments) =0;
831 // Execute the function using the specified V8 context. |object| is the
832 // receiver ('this' object) of the function. If |object| is empty the
833 // specified context's global object will be used. |arguments| is the list of
834 // arguments that will be passed to the function. Returns the function return
835 // value on success. Returns NULL if this method is called incorrectly or an
836 // exception is thrown.
838 /*--cef(optional_param=object)--*/
839 virtual CefRefPtr<CefV8Value> ExecuteFunctionWithContext(
840 CefRefPtr<CefV8Context> context,
841 CefRefPtr<CefV8Value> object,
842 const CefV8ValueList& arguments) =0;
846 // Class representing a V8 stack trace handle. V8 handles can only be accessed
847 // from the thread on which they are created. Valid threads for creating a V8
848 // handle include the render process main thread (TID_RENDERER) and WebWorker
849 // threads. A task runner for posting tasks on the associated thread can be
850 // retrieved via the CefV8Context::GetTaskRunner() method.
852 /*--cef(source=library)--*/
853 class CefV8StackTrace : public virtual CefBaseRefCounted {
856 // Returns the stack trace for the currently active context. |frame_limit| is
857 // the maximum number of frames that will be captured.
860 static CefRefPtr<CefV8StackTrace> GetCurrent(int frame_limit);
863 // Returns true if the underlying handle is valid and it can be accessed on
864 // the current thread. Do not call any other methods if this method returns
868 virtual bool IsValid() =0;
871 // Returns the number of stack frames.
874 virtual int GetFrameCount() =0;
877 // Returns the stack frame at the specified 0-based index.
880 virtual CefRefPtr<CefV8StackFrame> GetFrame(int index) =0;
884 // Class representing a V8 stack frame handle. V8 handles can only be accessed
885 // from the thread on which they are created. Valid threads for creating a V8
886 // handle include the render process main thread (TID_RENDERER) and WebWorker
887 // threads. A task runner for posting tasks on the associated thread can be
888 // retrieved via the CefV8Context::GetTaskRunner() method.
890 /*--cef(source=library)--*/
891 class CefV8StackFrame : public virtual CefBaseRefCounted {
894 // Returns true if the underlying handle is valid and it can be accessed on
895 // the current thread. Do not call any other methods if this method returns
899 virtual bool IsValid() =0;
902 // Returns the name of the resource script that contains the function.
905 virtual CefString GetScriptName() =0;
908 // Returns the name of the resource script that contains the function or the
909 // sourceURL value if the script name is undefined and its source ends with
910 // a "//@ sourceURL=..." string.
913 virtual CefString GetScriptNameOrSourceURL() =0;
916 // Returns the name of the function.
919 virtual CefString GetFunctionName() =0;
922 // Returns the 1-based line number for the function call or 0 if unknown.
925 virtual int GetLineNumber() =0;
928 // Returns the 1-based column offset on the line for the function call or 0 if
932 virtual int GetColumn() =0;
935 // Returns true if the function was compiled using eval().
938 virtual bool IsEval() =0;
941 // Returns true if the function was called as a constructor via "new".
944 virtual bool IsConstructor() =0;
947 #endif // CEF_INCLUDE_CEF_V8_H_