Chromium Embedded Framework (CEF)  126.2.0+g5c56e98+chromium-126.0.6478.62
CefV8Context Class Referenceabstract

Class representing a V8 context handle. More...

#include "include/cef_v8.h"

Inheritance diagram for CefV8Context:
CefBaseRefCounted

Public Member Functions

virtual CefRefPtr< CefTaskRunnerGetTaskRunner ()=0
 Returns the task runner associated with this context. More...
 
virtual bool IsValid ()=0
 Returns true if the underlying handle is valid and it can be accessed on the current thread. More...
 
virtual CefRefPtr< CefBrowserGetBrowser ()=0
 Returns the browser for this context. More...
 
virtual CefRefPtr< CefFrameGetFrame ()=0
 Returns the frame for this context. More...
 
virtual CefRefPtr< CefV8ValueGetGlobal ()=0
 Returns the global object for this context. More...
 
virtual bool Enter ()=0
 Enter this context. More...
 
virtual bool Exit ()=0
 Exit this context. More...
 
virtual bool IsSame (CefRefPtr< CefV8Context > that)=0
 Returns true if this object is pointing to the same handle as |that| object. More...
 
virtual bool Eval (const CefString &code, const CefString &script_url, int start_line, CefRefPtr< CefV8Value > &retval, CefRefPtr< CefV8Exception > &exception)=0
 Execute a string of JavaScript code in this V8 context. More...
 
- Public Member Functions inherited from CefBaseRefCounted
virtual void AddRef () const =0
 Called to increment the reference count for the object. More...
 
virtual bool Release () const =0
 Called to decrement the reference count for the object. More...
 
virtual bool HasOneRef () const =0
 Returns true if the reference count is 1. More...
 
virtual bool HasAtLeastOneRef () const =0
 Returns true if the reference count is at least 1. More...
 

Static Public Member Functions

static CefRefPtr< CefV8ContextGetCurrentContext ()
 Returns the current (top) context object in the V8 context stack. More...
 
static CefRefPtr< CefV8ContextGetEnteredContext ()
 Returns the entered (bottom) context object in the V8 context stack. More...
 
static bool InContext ()
 Returns true if V8 is currently inside a context. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CefBaseRefCounted
virtual ~CefBaseRefCounted ()
 

Detailed Description

Class representing a V8 context handle.

V8 handles can only be accessed from the thread on which they are created. Valid threads for creating a V8 handle include the render process main thread (TID_RENDERER) and WebWorker threads. A task runner for posting tasks on the associated thread can be retrieved via the CefV8Context::GetTaskRunner() method.

Member Function Documentation

◆ Enter()

virtual bool CefV8Context::Enter ( )
pure virtual

Enter this context.

A context must be explicitly entered before creating a V8 Object, Array, Function or Date asynchronously. Exit() must be called the same number of times as Enter() before releasing this context. V8 objects belong to the context in which they are created. Returns true if the scope was entered successfully.

◆ Eval()

virtual bool CefV8Context::Eval ( const CefString code,
const CefString script_url,
int  start_line,
CefRefPtr< CefV8Value > &  retval,
CefRefPtr< CefV8Exception > &  exception 
)
pure virtual

Execute a string of JavaScript code in this V8 context.

The |script_url| parameter is the URL where the script in question can be found, if any. The |start_line| parameter is the base line number to use for error reporting. On success |retval| will be set to the return value, if any, and the function will return true. On failure |exception| will be set to the exception, if any, and the function will return false.

◆ Exit()

virtual bool CefV8Context::Exit ( )
pure virtual

Exit this context.

Call this method only after calling Enter(). Returns true if the scope was exited successfully.

◆ GetBrowser()

virtual CefRefPtr<CefBrowser> CefV8Context::GetBrowser ( )
pure virtual

Returns the browser for this context.

This method will return an empty reference for WebWorker contexts.

◆ GetCurrentContext()

static CefRefPtr<CefV8Context> CefV8Context::GetCurrentContext ( )
static

Returns the current (top) context object in the V8 context stack.

◆ GetEnteredContext()

static CefRefPtr<CefV8Context> CefV8Context::GetEnteredContext ( )
static

Returns the entered (bottom) context object in the V8 context stack.

◆ GetFrame()

virtual CefRefPtr<CefFrame> CefV8Context::GetFrame ( )
pure virtual

Returns the frame for this context.

This method will return an empty reference for WebWorker contexts.

◆ GetGlobal()

virtual CefRefPtr<CefV8Value> CefV8Context::GetGlobal ( )
pure virtual

Returns the global object for this context.

The context must be entered before calling this method.

◆ GetTaskRunner()

virtual CefRefPtr<CefTaskRunner> CefV8Context::GetTaskRunner ( )
pure virtual

Returns the task runner associated with this context.

V8 handles can only be accessed from the thread on which they are created. This method can be called on any render process thread.

◆ InContext()

static bool CefV8Context::InContext ( )
static

Returns true if V8 is currently inside a context.

◆ IsSame()

virtual bool CefV8Context::IsSame ( CefRefPtr< CefV8Context that)
pure virtual

Returns true if this object is pointing to the same handle as |that| object.

◆ IsValid()

virtual bool CefV8Context::IsValid ( )
pure virtual

Returns true if the underlying handle is valid and it can be accessed on the current thread.

Do not call any other methods if this method returns false.


The documentation for this class was generated from the following file: