diff options
-rw-r--r-- | gin/isolate_holder.cc | 16 | ||||
-rw-r--r-- | gin/public/isolate_holder.h | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc index 1ddbe78..1929ebd 100644 --- a/gin/isolate_holder.cc +++ b/gin/isolate_holder.cc @@ -53,19 +53,14 @@ IsolateHolder::IsolateHolder() constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), base::SysInfo::NumberOfProcessors()); v8::SetResourceConstraints(isolate_, &constraints); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - isolate_data_.reset(new PerIsolateData(isolate_)); - InitFunctionTemplates(isolate_data_.get()); + Init(); } IsolateHolder::IsolateHolder(v8::Isolate* isolate) : isolate_owner_(false), isolate_(isolate) { EnsureV8Initialized(false); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - isolate_data_.reset(new PerIsolateData(isolate_)); + Init(); } IsolateHolder::~IsolateHolder() { @@ -74,4 +69,11 @@ IsolateHolder::~IsolateHolder() { isolate_->Dispose(); } +void IsolateHolder::Init() { + v8::Isolate::Scope isolate_scope(isolate_); + v8::HandleScope handle_scope(isolate_); + isolate_data_.reset(new PerIsolateData(isolate_)); + InitFunctionTemplates(isolate_data_.get()); +} + } // namespace gin diff --git a/gin/public/isolate_holder.h b/gin/public/isolate_holder.h index 0d0654e..d68e4d5 100644 --- a/gin/public/isolate_holder.h +++ b/gin/public/isolate_holder.h @@ -37,6 +37,8 @@ class GIN_EXPORT IsolateHolder { v8::Isolate* isolate() { return isolate_; } private: + void Init(); + bool isolate_owner_; v8::Isolate* isolate_; scoped_ptr<PerIsolateData> isolate_data_; |