summaryrefslogtreecommitdiffstats
path: root/gin
diff options
context:
space:
mode:
authorjochen <jochen@chromium.org>2014-09-12 02:53:43 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-12 09:57:53 +0000
commitb6d92a8f937cbabd2d97c034f873ecbb6e1f26fb (patch)
treee07d3b8d7953e22b62300b362294ddd0e80b6cdb /gin
parent6993ff96ffd1d66c38bcfbdc5c09c56a2c29330d (diff)
downloadchromium_src-b6d92a8f937cbabd2d97c034f873ecbb6e1f26fb.zip
chromium_src-b6d92a8f937cbabd2d97c034f873ecbb6e1f26fb.tar.gz
chromium_src-b6d92a8f937cbabd2d97c034f873ecbb6e1f26fb.tar.bz2
Remove deprecated IsolateHolder constructor
BUG=none R=marja@chromium.org Review URL: https://codereview.chromium.org/568523002 Cr-Commit-Position: refs/heads/master@{#294568}
Diffstat (limited to 'gin')
-rw-r--r--gin/isolate_holder.cc37
-rw-r--r--gin/public/isolate_holder.h20
2 files changed, 11 insertions, 46 deletions
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index 812be4e..b3d1673 100644
--- a/gin/isolate_holder.cc
+++ b/gin/isolate_holder.cc
@@ -18,6 +18,7 @@
namespace gin {
namespace {
+
v8::ArrayBuffer::Allocator* g_array_buffer_allocator = NULL;
bool GenerateEntropy(unsigned char* buffer, size_t amount) {
@@ -25,47 +26,29 @@ bool GenerateEntropy(unsigned char* buffer, size_t amount) {
return true;
}
-void EnsureV8Initialized(bool gin_managed) {
- static bool v8_is_initialized = false;
- static bool v8_is_gin_managed = false;
- if (v8_is_initialized) {
- CHECK_EQ(v8_is_gin_managed, gin_managed);
- return;
- }
- v8_is_initialized = true;
- v8_is_gin_managed = gin_managed;
-}
-
} // namespace
-IsolateHolder::IsolateHolder()
- : isolate_owner_(true) {
- EnsureV8Initialized(true);
+IsolateHolder::IsolateHolder() {
+ CHECK(g_array_buffer_allocator)
+ << "You need to invoke gin::IsolateHolder::Initialize first";
isolate_ = v8::Isolate::New();
v8::ResourceConstraints constraints;
constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
base::SysInfo::AmountOfVirtualMemory(),
base::SysInfo::NumberOfProcessors());
v8::SetResourceConstraints(isolate_, &constraints);
- Init(g_array_buffer_allocator);
-}
-
-IsolateHolder::IsolateHolder(v8::Isolate* isolate,
- v8::ArrayBuffer::Allocator* allocator)
- : isolate_owner_(false), isolate_(isolate) {
- EnsureV8Initialized(false);
- Init(allocator);
+ isolate_data_.reset(new PerIsolateData(isolate_, g_array_buffer_allocator));
}
IsolateHolder::~IsolateHolder() {
isolate_data_.reset();
- if (isolate_owner_)
- isolate_->Dispose();
+ isolate_->Dispose();
}
// static
void IsolateHolder::Initialize(ScriptMode mode,
v8::ArrayBuffer::Allocator* allocator) {
+ CHECK(allocator);
static bool v8_is_initialized = false;
if (v8_is_initialized)
return;
@@ -81,10 +64,4 @@ void IsolateHolder::Initialize(ScriptMode mode,
v8_is_initialized = true;
}
-void IsolateHolder::Init(v8::ArrayBuffer::Allocator* allocator) {
- v8::Isolate::Scope isolate_scope(isolate_);
- v8::HandleScope handle_scope(isolate_);
- isolate_data_.reset(new PerIsolateData(isolate_, allocator));
-}
-
} // namespace gin
diff --git a/gin/public/isolate_holder.h b/gin/public/isolate_holder.h
index af01782..da65fac 100644
--- a/gin/public/isolate_holder.h
+++ b/gin/public/isolate_holder.h
@@ -14,16 +14,10 @@ namespace gin {
class PerIsolateData;
-// To embed Gin, first create an instance of IsolateHolder to hold the
-// v8::Isolate in which you will execute JavaScript. You might wish to subclass
-// IsolateHolder if you want to tie more state to the lifetime of the isolate.
-//
-// You can use gin in two modes: either gin manages V8, or the gin-embedder
-// manages gin. If gin manages V8, use the IsolateHolder constructor that does
-// not take an v8::Isolate parameter, otherwise, the gin-embedder needs to
-// create v8::Isolates and pass them to IsolateHolder.
-//
-// It is not possible to mix the two.
+// To embed Gin, first initialize gin using IsolateHolder::Initialize and then
+// create an instance of IsolateHolder to hold the v8::Isolate in which you
+// will execute JavaScript. You might wish to subclass IsolateHolder if you
+// want to tie more state to the lifetime of the isolate.
class GIN_EXPORT IsolateHolder {
public:
// Controls whether or not V8 should only accept strict mode scripts.
@@ -33,9 +27,6 @@ class GIN_EXPORT IsolateHolder {
};
IsolateHolder();
- // Deprecated.
- IsolateHolder(v8::Isolate* isolate, v8::ArrayBuffer::Allocator* allocator);
-
~IsolateHolder();
// Should be invoked once before creating IsolateHolder instances to
@@ -46,9 +37,6 @@ class GIN_EXPORT IsolateHolder {
v8::Isolate* isolate() { return isolate_; }
private:
- void Init(v8::ArrayBuffer::Allocator* allocator);
-
- bool isolate_owner_;
v8::Isolate* isolate_;
scoped_ptr<PerIsolateData> isolate_data_;