mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-10 17:10:55 +01:00
Remove the CefSettings.context_safety_implementation option (issue #1853).
The default hash implementation will now always be used.
This commit is contained in:
parent
5315bd2548
commit
44a7cb8901
@ -354,28 +354,6 @@ typedef struct _cef_settings_t {
|
|||||||
///
|
///
|
||||||
int uncaught_exception_stack_size;
|
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.
|
// Set to true (1) to ignore errors related to invalid SSL certificates.
|
||||||
// Enabling this setting can lead to potential security vulnerabilities like
|
// 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->pack_loading_disabled = src->pack_loading_disabled;
|
||||||
target->remote_debugging_port = src->remote_debugging_port;
|
target->remote_debugging_port = src->remote_debugging_port;
|
||||||
target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
|
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->ignore_certificate_errors = src->ignore_certificate_errors;
|
||||||
target->enable_net_security_expiration =
|
target->enable_net_security_expiration =
|
||||||
src->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
|
// Propagate the following switches to the renderer command line (along with
|
||||||
// any associated values) if present in the browser command line.
|
// any associated values) if present in the browser command line.
|
||||||
static const char* const kSwitchNames[] = {
|
static const char* const kSwitchNames[] = {
|
||||||
switches::kContextSafetyImplementation,
|
|
||||||
switches::kDisableExtensions,
|
switches::kDisableExtensions,
|
||||||
switches::kDisablePdfExtension,
|
switches::kDisablePdfExtension,
|
||||||
switches::kDisableScrollBounce,
|
switches::kDisableScrollBounce,
|
||||||
|
@ -29,9 +29,6 @@ const char kDisablePackLoading[] = "disable-pack-loading";
|
|||||||
// Stack size for uncaught exceptions.
|
// Stack size for uncaught exceptions.
|
||||||
const char kUncaughtExceptionStackSize[] = "uncaught-exception-stack-size";
|
const char kUncaughtExceptionStackSize[] = "uncaught-exception-stack-size";
|
||||||
|
|
||||||
// Context safety implementation type.
|
|
||||||
const char kContextSafetyImplementation[] = "context-safety-implementation";
|
|
||||||
|
|
||||||
// Default encoding.
|
// Default encoding.
|
||||||
const char kDefaultEncoding[] = "default-encoding";
|
const char kDefaultEncoding[] = "default-encoding";
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ extern const char kResourcesDirPath[];
|
|||||||
extern const char kLocalesDirPath[];
|
extern const char kLocalesDirPath[];
|
||||||
extern const char kDisablePackLoading[];
|
extern const char kDisablePackLoading[];
|
||||||
extern const char kUncaughtExceptionStackSize[];
|
extern const char kUncaughtExceptionStackSize[];
|
||||||
extern const char kContextSafetyImplementation[];
|
|
||||||
extern const char kDefaultEncoding[];
|
extern const char kDefaultEncoding[];
|
||||||
extern const char kDisableJavascriptOpenWindows[];
|
extern const char kDisableJavascriptOpenWindows[];
|
||||||
extern const char kDisableJavascriptCloseWindows[];
|
extern const char kDisableJavascriptCloseWindows[];
|
||||||
|
@ -433,11 +433,6 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
|||||||
command_line->AppendSwitchASCII(switches::kUncaughtExceptionStackSize,
|
command_line->AppendSwitchASCII(switches::kUncaughtExceptionStackSize,
|
||||||
base::IntToString(settings.uncaught_exception_stack_size));
|
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()) {
|
if (content_client_.application().get()) {
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static const char kCefTrackObject[] = "Cef::TrackObject";
|
static const char kCefTrackObject[] = "Cef::TrackObject";
|
||||||
static const char kCefContextState[] = "Cef::ContextState";
|
|
||||||
|
|
||||||
void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
|
void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
|
||||||
v8::Handle<v8::Value> data);
|
v8::Handle<v8::Value> data);
|
||||||
@ -90,25 +89,10 @@ class CefV8IsolateManager {
|
|||||||
CefV8IsolateManager()
|
CefV8IsolateManager()
|
||||||
: isolate_(v8::Isolate::GetCurrent()),
|
: isolate_(v8::Isolate::GetCurrent()),
|
||||||
task_runner_(CefContentRendererClient::Get()->GetCurrentTaskRunner()),
|
task_runner_(CefContentRendererClient::Get()->GetCurrentTaskRunner()),
|
||||||
context_safety_impl_(IMPL_HASH),
|
|
||||||
message_listener_registered_(false),
|
message_listener_registered_(false),
|
||||||
worker_id_(0) {
|
worker_id_(0) {
|
||||||
DCHECK(isolate_);
|
DCHECK(isolate_);
|
||||||
DCHECK(task_runner_.get());
|
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() {
|
~CefV8IsolateManager() {
|
||||||
DCHECK_EQ(isolate_, v8::Isolate::GetCurrent());
|
DCHECK_EQ(isolate_, v8::Isolate::GetCurrent());
|
||||||
@ -120,9 +104,6 @@ class CefV8IsolateManager {
|
|||||||
DCHECK_EQ(isolate_, v8::Isolate::GetCurrent());
|
DCHECK_EQ(isolate_, v8::Isolate::GetCurrent());
|
||||||
DCHECK(context.IsEmpty() || isolate_ == context->GetIsolate());
|
DCHECK(context.IsEmpty() || isolate_ == context->GetIsolate());
|
||||||
|
|
||||||
if (context_safety_impl_ == IMPL_DISABLED)
|
|
||||||
return scoped_refptr<CefV8ContextState>();
|
|
||||||
|
|
||||||
if (context.IsEmpty()) {
|
if (context.IsEmpty()) {
|
||||||
if (isolate_->InContext())
|
if (isolate_->InContext())
|
||||||
context = isolate_->GetCurrentContext();
|
context = isolate_->GetCurrentContext();
|
||||||
@ -130,7 +111,6 @@ class CefV8IsolateManager {
|
|||||||
return scoped_refptr<CefV8ContextState>();
|
return scoped_refptr<CefV8ContextState>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context_safety_impl_ == IMPL_HASH) {
|
|
||||||
int hash = context->Global()->GetIdentityHash();
|
int hash = context->Global()->GetIdentityHash();
|
||||||
ContextMap::const_iterator it = context_map_.find(hash);
|
ContextMap::const_iterator it = context_map_.find(hash);
|
||||||
if (it != context_map_.end())
|
if (it != context_map_.end())
|
||||||
@ -140,55 +120,18 @@ class CefV8IsolateManager {
|
|||||||
context_map_.insert(std::make_pair(hash, state));
|
context_map_.insert(std::make_pair(hash, state));
|
||||||
|
|
||||||
return 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());
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr<CefV8ContextState> state = new CefV8ContextState();
|
|
||||||
SetPrivate(context, object, kCefContextState,
|
|
||||||
v8::External::New(isolate_, state.get()));
|
|
||||||
|
|
||||||
// Reference will be released in ReleaseContext.
|
|
||||||
state->AddRef();
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseContext(v8::Local<v8::Context> context) {
|
void ReleaseContext(v8::Local<v8::Context> context) {
|
||||||
DCHECK_EQ(isolate_, v8::Isolate::GetCurrent());
|
DCHECK_EQ(isolate_, v8::Isolate::GetCurrent());
|
||||||
DCHECK_EQ(isolate_, context->GetIsolate());
|
DCHECK_EQ(isolate_, context->GetIsolate());
|
||||||
|
|
||||||
if (context_safety_impl_ == IMPL_DISABLED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (context_safety_impl_ == IMPL_HASH) {
|
|
||||||
int hash = context->Global()->GetIdentityHash();
|
int hash = context->Global()->GetIdentityHash();
|
||||||
ContextMap::iterator it = context_map_.find(hash);
|
ContextMap::iterator it = context_map_.find(hash);
|
||||||
if (it != context_map_.end()) {
|
if (it != context_map_.end()) {
|
||||||
it->second->Detach();
|
it->second->Detach();
|
||||||
context_map_.erase(it);
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddGlobalTrackObject(CefTrackNode* object) {
|
void AddGlobalTrackObject(CefTrackNode* object) {
|
||||||
@ -236,14 +179,6 @@ class CefV8IsolateManager {
|
|||||||
v8::Isolate* isolate_;
|
v8::Isolate* isolate_;
|
||||||
scoped_refptr<base::SequencedTaskRunner> task_runner_;
|
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;
|
typedef std::map<int, scoped_refptr<CefV8ContextState> > ContextMap;
|
||||||
ContextMap context_map_;
|
ContextMap context_map_;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user