Ensure that on Windows 7, relaunching the browser via chrome://restart or changing...
[chromium-blink-merge.git] / gin / public / isolate_holder.h
blobda65facff63d6fe5d20b5c4c43fc9f7239bb08b6
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
3 // found in the LICENSE file.
5 #ifndef GIN_PUBLIC_ISOLATE_HOLDER_H_
6 #define GIN_PUBLIC_ISOLATE_HOLDER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "gin/gin_export.h"
11 #include "v8/include/v8.h"
13 namespace gin {
15 class PerIsolateData;
17 // To embed Gin, first initialize gin using IsolateHolder::Initialize and then
18 // create an instance of IsolateHolder to hold the v8::Isolate in which you
19 // will execute JavaScript. You might wish to subclass IsolateHolder if you
20 // want to tie more state to the lifetime of the isolate.
21 class GIN_EXPORT IsolateHolder {
22 public:
23 // Controls whether or not V8 should only accept strict mode scripts.
24 enum ScriptMode {
25 kNonStrictMode,
26 kStrictMode
29 IsolateHolder();
30 ~IsolateHolder();
32 // Should be invoked once before creating IsolateHolder instances to
33 // initialize V8 and Gin.
34 static void Initialize(ScriptMode mode,
35 v8::ArrayBuffer::Allocator* allocator);
37 v8::Isolate* isolate() { return isolate_; }
39 private:
40 v8::Isolate* isolate_;
41 scoped_ptr<PerIsolateData> isolate_data_;
43 DISALLOW_COPY_AND_ASSIGN(IsolateHolder);
46 } // namespace gin
48 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_