Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: gin/isolate_holder.cc

Issue 568523002: Remove deprecated IsolateHolder constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gin/public/isolate_holder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/isolate_holder.cc
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index 812be4ef7231554138a3cb8d8d37fd49d2572e1c..b3d16730acf296ceec8bd3ca8fccd26625681158 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
« no previous file with comments | « no previous file | gin/public/isolate_holder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698