| OLD | NEW |
| 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 #ifndef GIN_PUBLIC_ISOLATE_HOLDER_H_ | 5 #ifndef GIN_PUBLIC_ISOLATE_HOLDER_H_ |
| 6 #define GIN_PUBLIC_ISOLATE_HOLDER_H_ | 6 #define GIN_PUBLIC_ISOLATE_HOLDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "gin/gin_export.h" | 10 #include "gin/gin_export.h" |
| 11 | 11 #include "v8/include/v8.h" |
| 12 namespace v8 { | |
| 13 class Isolate; | |
| 14 } | |
| 15 | 12 |
| 16 namespace gin { | 13 namespace gin { |
| 17 | 14 |
| 18 class PerIsolateData; | 15 class PerIsolateData; |
| 19 | 16 |
| 20 // To embed Gin, first create an instance of IsolateHolder to hold the | 17 // To embed Gin, first create an instance of IsolateHolder to hold the |
| 21 // v8::Isolate in which you will execute JavaScript. You might wish to subclass | 18 // v8::Isolate in which you will execute JavaScript. You might wish to subclass |
| 22 // IsolateHolder if you want to tie more state to the lifetime of the | 19 // IsolateHolder if you want to tie more state to the lifetime of the |
| 23 // | 20 // |
| 24 // You can use gin in two modes: either gin manages V8, or the gin-embedder | 21 // You can use gin in two modes: either gin manages V8, or the gin-embedder |
| 25 // manages gin. If gin manages V8, use the IsolateHolder constructor without | 22 // manages gin. If gin manages V8, use the IsolateHolder constructor without |
| 26 // parameters, otherwise, the gin-embedder needs to create v8::Isolates and | 23 // parameters, otherwise, the gin-embedder needs to create v8::Isolates and |
| 27 // pass them to IsolateHolder. | 24 // pass them to IsolateHolder. |
| 28 // | 25 // |
| 29 // It is not possible to mix the two. | 26 // It is not possible to mix the two. |
| 30 class GIN_EXPORT IsolateHolder { | 27 class GIN_EXPORT IsolateHolder { |
| 31 public: | 28 public: |
| 32 IsolateHolder(); | 29 IsolateHolder(); |
| 30 IsolateHolder(v8::Isolate* isolate, v8::ArrayBuffer::Allocator* allocator); |
| 31 |
| 32 // TODO(jochen): Remove. |
| 33 explicit IsolateHolder(v8::Isolate* isolate); | 33 explicit IsolateHolder(v8::Isolate* isolate); |
| 34 | 34 |
| 35 ~IsolateHolder(); | 35 ~IsolateHolder(); |
| 36 | 36 |
| 37 v8::Isolate* isolate() { return isolate_; } | 37 v8::Isolate* isolate() { return isolate_; } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 void Init(); | 40 void Init(v8::ArrayBuffer::Allocator* allocator); |
| 41 | 41 |
| 42 bool isolate_owner_; | 42 bool isolate_owner_; |
| 43 v8::Isolate* isolate_; | 43 v8::Isolate* isolate_; |
| 44 scoped_ptr<PerIsolateData> isolate_data_; | 44 scoped_ptr<PerIsolateData> isolate_data_; |
| 45 | 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); | 46 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 } // namespace gin | 49 } // namespace gin |
| 50 | 50 |
| 51 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ | 51 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ |
| OLD | NEW |