Chromium Code Reviews| 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 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
| 10 #include "base/files/memory_mapped_file.h" | |
| 11 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
| 9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 10 #include "gin/gin_export.h" | 13 #include "gin/gin_export.h" |
| 11 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
| 12 | 15 |
| 13 namespace gin { | 16 namespace gin { |
| 14 | 17 |
| 15 class PerIsolateData; | 18 class PerIsolateData; |
| 16 | 19 |
| 17 // To embed Gin, first initialize gin using IsolateHolder::Initialize and then | 20 // 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 | 21 // create an instance of IsolateHolder to hold the v8::Isolate in which you |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 29 IsolateHolder(); | 32 IsolateHolder(); |
| 30 ~IsolateHolder(); | 33 ~IsolateHolder(); |
| 31 | 34 |
| 32 // Should be invoked once before creating IsolateHolder instances to | 35 // Should be invoked once before creating IsolateHolder instances to |
| 33 // initialize V8 and Gin. | 36 // initialize V8 and Gin. |
| 34 static void Initialize(ScriptMode mode, | 37 static void Initialize(ScriptMode mode, |
| 35 v8::ArrayBuffer::Allocator* allocator); | 38 v8::ArrayBuffer::Allocator* allocator); |
| 36 | 39 |
| 37 v8::Isolate* isolate() { return isolate_; } | 40 v8::Isolate* isolate() { return isolate_; } |
| 38 | 41 |
| 42 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
| 43 #ifdef OS_ANDROID | |
| 44 static bool LoadV8SnapshotFD(int natives_fd, int snapshot_fd); | |
| 45 #endif | |
| 46 static bool LoadV8Snapshot(); | |
| 47 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
| 48 | |
| 39 private: | 49 private: |
| 40 v8::Isolate* isolate_; | 50 v8::Isolate* isolate_; |
| 41 scoped_ptr<PerIsolateData> isolate_data_; | 51 scoped_ptr<PerIsolateData> isolate_data_; |
| 42 | 52 |
| 53 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
| 54 static base::MemoryMappedFile mapped_natives; | |
| 55 static base::MemoryMappedFile mapped_snapshot; | |
| 56 static bool read_snapshot; | |
|
rmcilroy
2014/09/23 10:04:20
You shouldn't have these static members here (you
baixo
2014/09/23 11:36:46
Done.
| |
| 57 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
| 58 | |
| 43 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); | 59 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); |
| 44 }; | 60 }; |
| 45 | 61 |
| 46 } // namespace gin | 62 } // namespace gin |
| 47 | 63 |
| 48 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ | 64 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ |
| OLD | NEW |