diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 375b7576f..a1801aeee 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -354,28 +354,6 @@ typedef struct _cef_settings_t { /// int uncaught_exception_stack_size; - /// - // By default CEF V8 references will be invalidated (the IsValid() method will - // return false) after the owning context has been released. This reduces the - // need for external record keeping and avoids crashes due to the use of V8 - // references after the associated context has been released. - // - // CEF currently offers two context safety implementations with different - // performance characteristics. The default implementation (value of 0) uses a - // map of hash values and should provide better performance in situations with - // a small number contexts. The alternate implementation (value of 1) uses a - // hidden value attached to each context and should provide better performance - // in situations with a large number of contexts. - // - // If you need better performance in the creation of V8 references and you - // plan to manually track context lifespan you can disable context safety by - // specifying a value of -1. - // - // Also configurable using the "context-safety-implementation" command-line - // switch. - /// - int context_safety_implementation; - /// // Set to true (1) to ignore errors related to invalid SSL certificates. // Enabling this setting can lead to potential security vulnerabilities like diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index 4108a933e..5f6a42d9d 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -601,7 +601,6 @@ struct CefSettingsTraits { target->pack_loading_disabled = src->pack_loading_disabled; target->remote_debugging_port = src->remote_debugging_port; target->uncaught_exception_stack_size = src->uncaught_exception_stack_size; - target->context_safety_implementation = src->context_safety_implementation; target->ignore_certificate_errors = src->ignore_certificate_errors; target->enable_net_security_expiration = src->enable_net_security_expiration; diff --git a/libcef/browser/content_browser_client.cc b/libcef/browser/content_browser_client.cc index fdf6363f6..16462ae6d 100644 --- a/libcef/browser/content_browser_client.cc +++ b/libcef/browser/content_browser_client.cc @@ -647,7 +647,6 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches( // Propagate the following switches to the renderer command line (along with // any associated values) if present in the browser command line. static const char* const kSwitchNames[] = { - switches::kContextSafetyImplementation, switches::kDisableExtensions, switches::kDisablePdfExtension, switches::kDisableScrollBounce, diff --git a/libcef/common/cef_switches.cc b/libcef/common/cef_switches.cc index 03ef0b95d..23650cc0f 100644 --- a/libcef/common/cef_switches.cc +++ b/libcef/common/cef_switches.cc @@ -29,9 +29,6 @@ const char kDisablePackLoading[] = "disable-pack-loading"; // Stack size for uncaught exceptions. const char kUncaughtExceptionStackSize[] = "uncaught-exception-stack-size"; -// Context safety implementation type. -const char kContextSafetyImplementation[] = "context-safety-implementation"; - // Default encoding. const char kDefaultEncoding[] = "default-encoding"; diff --git a/libcef/common/cef_switches.h b/libcef/common/cef_switches.h index 799d705d1..edb043a11 100644 --- a/libcef/common/cef_switches.h +++ b/libcef/common/cef_switches.h @@ -23,7 +23,6 @@ extern const char kResourcesDirPath[]; extern const char kLocalesDirPath[]; extern const char kDisablePackLoading[]; extern const char kUncaughtExceptionStackSize[]; -extern const char kContextSafetyImplementation[]; extern const char kDefaultEncoding[]; extern const char kDisableJavascriptOpenWindows[]; extern const char kDisableJavascriptCloseWindows[]; diff --git a/libcef/common/main_delegate.cc b/libcef/common/main_delegate.cc index f8bff50ea..88fa2d0e3 100644 --- a/libcef/common/main_delegate.cc +++ b/libcef/common/main_delegate.cc @@ -433,11 +433,6 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) { command_line->AppendSwitchASCII(switches::kUncaughtExceptionStackSize, base::IntToString(settings.uncaught_exception_stack_size)); } - - if (settings.context_safety_implementation != 0) { - command_line->AppendSwitchASCII(switches::kContextSafetyImplementation, - base::IntToString(settings.context_safety_implementation)); - } } if (content_client_.application().get()) { diff --git a/libcef/renderer/v8_impl.cc b/libcef/renderer/v8_impl.cc index 61fbeb641..6fccfbd3e 100644 --- a/libcef/renderer/v8_impl.cc +++ b/libcef/renderer/v8_impl.cc @@ -40,7 +40,6 @@ namespace { static const char kCefTrackObject[] = "Cef::TrackObject"; -static const char kCefContextState[] = "Cef::ContextState"; void MessageListenerCallbackImpl(v8::Handle message, v8::Handle data); @@ -90,25 +89,10 @@ class CefV8IsolateManager { CefV8IsolateManager() : isolate_(v8::Isolate::GetCurrent()), task_runner_(CefContentRendererClient::Get()->GetCurrentTaskRunner()), - context_safety_impl_(IMPL_HASH), message_listener_registered_(false), worker_id_(0) { DCHECK(isolate_); DCHECK(task_runner_.get()); - - const base::CommandLine* command_line = - base::CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(switches::kContextSafetyImplementation)) { - std::string value = command_line->GetSwitchValueASCII( - switches::kContextSafetyImplementation); - int mode; - if (base::StringToInt(value, &mode)) { - if (mode < 0) - context_safety_impl_ = IMPL_DISABLED; - else if (mode == 1) - context_safety_impl_ = IMPL_VALUE; - } - } } ~CefV8IsolateManager() { DCHECK_EQ(isolate_, v8::Isolate::GetCurrent()); @@ -120,9 +104,6 @@ class CefV8IsolateManager { DCHECK_EQ(isolate_, v8::Isolate::GetCurrent()); DCHECK(context.IsEmpty() || isolate_ == context->GetIsolate()); - if (context_safety_impl_ == IMPL_DISABLED) - return scoped_refptr(); - if (context.IsEmpty()) { if (isolate_->InContext()) context = isolate_->GetCurrentContext(); @@ -130,64 +111,26 @@ class CefV8IsolateManager { return scoped_refptr(); } - if (context_safety_impl_ == IMPL_HASH) { - int hash = context->Global()->GetIdentityHash(); - ContextMap::const_iterator it = context_map_.find(hash); - if (it != context_map_.end()) - return it->second; + int hash = context->Global()->GetIdentityHash(); + ContextMap::const_iterator it = context_map_.find(hash); + if (it != context_map_.end()) + return it->second; - scoped_refptr state = new CefV8ContextState(); - context_map_.insert(std::make_pair(hash, state)); + scoped_refptr state = new CefV8ContextState(); + context_map_.insert(std::make_pair(hash, state)); - return state; - } else { - v8::Local object = context->Global(); - - v8::Local value; - if (GetPrivate(context, object, kCefContextState, &value)) { - return static_cast( - v8::External::Cast(*value)->Value()); - } - - scoped_refptr state = new CefV8ContextState(); - SetPrivate(context, object, kCefContextState, - v8::External::New(isolate_, state.get())); - - // Reference will be released in ReleaseContext. - state->AddRef(); - - return state; - } + return state; } void ReleaseContext(v8::Local context) { DCHECK_EQ(isolate_, v8::Isolate::GetCurrent()); DCHECK_EQ(isolate_, context->GetIsolate()); - if (context_safety_impl_ == IMPL_DISABLED) - return; - - if (context_safety_impl_ == IMPL_HASH) { - int hash = context->Global()->GetIdentityHash(); - ContextMap::iterator it = context_map_.find(hash); - if (it != context_map_.end()) { - it->second->Detach(); - context_map_.erase(it); - } - } else { - v8::Local object = context->Global(); - - v8::Local value; - if (GetPrivate(context, object, kCefContextState, &value)) { - scoped_refptr state = - static_cast( - v8::External::Cast(*value)->Value()); - state->Detach(); - DeletePrivate(context, object, kCefContextState); - - // Match the AddRef in GetContextState. - state->Release(); - } + int hash = context->Global()->GetIdentityHash(); + ContextMap::iterator it = context_map_.find(hash); + if (it != context_map_.end()) { + it->second->Detach(); + context_map_.erase(it); } } @@ -236,14 +179,6 @@ class CefV8IsolateManager { v8::Isolate* isolate_; scoped_refptr task_runner_; - enum ContextSafetyImpl { - IMPL_DISABLED, - IMPL_HASH, - IMPL_VALUE, - }; - ContextSafetyImpl context_safety_impl_; - - // Used with IMPL_HASH. typedef std::map > ContextMap; ContextMap context_map_;