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

Side by Side Diff: gin/isolate_holder.cc

Issue 76923003: First cut at gin::Bind() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gin/public/isolate_holder.h" 5 #include "gin/public/isolate_holder.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "base/sys_info.h" 12 #include "base/sys_info.h"
13 #include "gin/array_buffer.h" 13 #include "gin/array_buffer.h"
14 #include "gin/function_template.h"
14 #include "gin/per_isolate_data.h" 15 #include "gin/per_isolate_data.h"
15 16
16 namespace gin { 17 namespace gin {
17 18
18 namespace { 19 namespace {
19 20
20 bool GenerateEntropy(unsigned char* buffer, size_t amount) { 21 bool GenerateEntropy(unsigned char* buffer, size_t amount) {
21 base::RandBytes(buffer, amount); 22 base::RandBytes(buffer, amount);
22 return true; 23 return true;
23 } 24 }
(...skipping 21 matching lines...) Expand all
45 IsolateHolder::IsolateHolder() 46 IsolateHolder::IsolateHolder()
46 : isolate_owner_(true) { 47 : isolate_owner_(true) {
47 EnsureV8Initialized(true); 48 EnsureV8Initialized(true);
48 isolate_ = v8::Isolate::New(); 49 isolate_ = v8::Isolate::New();
49 v8::ResourceConstraints constraints; 50 v8::ResourceConstraints constraints;
50 constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory()); 51 constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory());
51 v8::SetResourceConstraints(isolate_, &constraints); 52 v8::SetResourceConstraints(isolate_, &constraints);
52 v8::Isolate::Scope isolate_scope(isolate_); 53 v8::Isolate::Scope isolate_scope(isolate_);
53 v8::HandleScope handle_scope(isolate_); 54 v8::HandleScope handle_scope(isolate_);
54 isolate_data_.reset(new PerIsolateData(isolate_)); 55 isolate_data_.reset(new PerIsolateData(isolate_));
56 CallbackHolderBase::EnsureRegistered(isolate_data_.get());
55 } 57 }
56 58
57 IsolateHolder::IsolateHolder(v8::Isolate* isolate) 59 IsolateHolder::IsolateHolder(v8::Isolate* isolate)
58 : isolate_owner_(false), 60 : isolate_owner_(false),
59 isolate_(isolate) { 61 isolate_(isolate) {
60 EnsureV8Initialized(false); 62 EnsureV8Initialized(false);
61 v8::Isolate::Scope isolate_scope(isolate_); 63 v8::Isolate::Scope isolate_scope(isolate_);
62 v8::HandleScope handle_scope(isolate_); 64 v8::HandleScope handle_scope(isolate_);
63 isolate_data_.reset(new PerIsolateData(isolate_)); 65 isolate_data_.reset(new PerIsolateData(isolate_));
64 } 66 }
65 67
66 IsolateHolder::~IsolateHolder() { 68 IsolateHolder::~IsolateHolder() {
67 isolate_data_.reset(); 69 isolate_data_.reset();
68 if (isolate_owner_) 70 if (isolate_owner_)
69 isolate_->Dispose(); 71 isolate_->Dispose();
70 } 72 }
71 73
72 } // namespace gin 74 } // namespace gin
OLDNEW
« gin/function_template.h ('K') | « gin/gin.gyp ('k') | gin/test/gtest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698