Commit 77097ffa authored by Marshall Greenblatt's avatar Marshall Greenblatt

Remove the CefSettings.context_safety_implementation option (issue #1853).

The default hash implementation will now always be used.
parent 96f91083
......@@ -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
......
......@@ -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;
......
......@@ -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,
......
......@@ -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";
......
......@@ -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[];
......
......@@ -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()) {
......
......@@ -40,7 +40,6 @@
namespace {
static const char kCefTrackObject[] = "Cef::TrackObject";
static const char kCefContextState[] = "Cef::ContextState";
void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
v8::Handle<v8::Value> 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<CefV8ContextState>();
if (context.IsEmpty()) {
if (isolate_->InContext())
context = isolate_->GetCurrentContext();
......@@ -130,64 +111,26 @@ class CefV8IsolateManager {
return scoped_refptr<CefV8ContextState>();
}
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;
scoped_refptr<CefV8ContextState> state = new CefV8ContextState();
context_map_.insert(std::make_pair(hash, state));
return state;
} else {
v8::Local<v8::Object> object = context->Global();
v8::Local<v8::Value> value;
if (GetPrivate(context, object, kCefContextState, &value)) {
return static_cast<CefV8ContextState*>(
v8::External::Cast(*value)->Value());
}
int hash = context->Global()->GetIdentityHash();
ContextMap::const_iterator it = context_map_.find(hash);
if (it != context_map_.end())
return it->second;
scoped_refptr<CefV8ContextState> state = new CefV8ContextState();
SetPrivate(context, object, kCefContextState,
v8::External::New(isolate_, state.get()));
scoped_refptr<CefV8ContextState> state = new CefV8ContextState();
context_map_.insert(std::make_pair(hash, state));
// Reference will be released in ReleaseContext.
state->AddRef();
return state;
}
return state;
}
void ReleaseContext(v8::Local<v8::Context> 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<v8::Object> object = context->Global();
v8::Local<v8::Value> value;
if (GetPrivate(context, object, kCefContextState, &value)) {
scoped_refptr<CefV8ContextState> state =
static_cast<CefV8ContextState*>(
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<base::SequencedTaskRunner> task_runner_;
enum ContextSafetyImpl {
IMPL_DISABLED,
IMPL_HASH,
IMPL_VALUE,
};
ContextSafetyImpl context_safety_impl_;
// Used with IMPL_HASH.
typedef std::map<int, scoped_refptr<CefV8ContextState> > ContextMap;
ContextMap context_map_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment