| 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 #include "gin/v8_initializer.h" | 5 #include "gin/v8_initializer.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/debug/alias.h" | 8 #include "base/debug/alias.h" |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 // static | 355 // static |
| 356 base::PlatformFile V8Initializer::GetOpenSnapshotFileForChildProcesses( | 356 base::PlatformFile V8Initializer::GetOpenSnapshotFileForChildProcesses( |
| 357 base::MemoryMappedFile::Region* region_out) { | 357 base::MemoryMappedFile::Region* region_out) { |
| 358 OpenSnapshotFileIfNecessary(); | 358 OpenSnapshotFileIfNecessary(); |
| 359 *region_out = g_snapshot_region; | 359 *region_out = g_snapshot_region; |
| 360 return g_snapshot_pf; | 360 return g_snapshot_pf; |
| 361 } | 361 } |
| 362 #endif // defined(V8_USE_EXTERNAL_STARTUP_DATA) | 362 #endif // defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 363 | 363 |
| 364 // static | 364 // static |
| 365 void V8Initializer::Initialize(gin::IsolateHolder::ScriptMode mode) { | 365 void V8Initializer::Initialize(IsolateHolder::ScriptMode mode, |
| 366 IsolateHolder::V8ExtrasMode v8_extras_mode) { |
| 366 static bool v8_is_initialized = false; | 367 static bool v8_is_initialized = false; |
| 367 if (v8_is_initialized) | 368 if (v8_is_initialized) |
| 368 return; | 369 return; |
| 369 | 370 |
| 370 v8::V8::InitializePlatform(V8Platform::Get()); | 371 v8::V8::InitializePlatform(V8Platform::Get()); |
| 371 | 372 |
| 372 if (gin::IsolateHolder::kStrictMode == mode) { | 373 if (IsolateHolder::kStrictMode == mode) { |
| 373 static const char use_strict[] = "--use_strict"; | 374 static const char use_strict[] = "--use_strict"; |
| 374 v8::V8::SetFlagsFromString(use_strict, sizeof(use_strict) - 1); | 375 v8::V8::SetFlagsFromString(use_strict, sizeof(use_strict) - 1); |
| 375 } | 376 } |
| 377 if (IsolateHolder::kExperimentalV8Extras == v8_extras_mode) { |
| 378 static const char flag[] = "--experimental_extras"; |
| 379 v8::V8::SetFlagsFromString(flag, sizeof(flag) - 1); |
| 380 } |
| 376 | 381 |
| 377 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 382 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 378 v8::StartupData natives; | 383 v8::StartupData natives; |
| 379 natives.data = reinterpret_cast<const char*>(g_mapped_natives->data()); | 384 natives.data = reinterpret_cast<const char*>(g_mapped_natives->data()); |
| 380 natives.raw_size = static_cast<int>(g_mapped_natives->length()); | 385 natives.raw_size = static_cast<int>(g_mapped_natives->length()); |
| 381 v8::V8::SetNativesDataBlob(&natives); | 386 v8::V8::SetNativesDataBlob(&natives); |
| 382 | 387 |
| 383 if (g_mapped_snapshot != NULL) { | 388 if (g_mapped_snapshot != NULL) { |
| 384 v8::StartupData snapshot; | 389 v8::StartupData snapshot; |
| 385 snapshot.data = reinterpret_cast<const char*>(g_mapped_snapshot->data()); | 390 snapshot.data = reinterpret_cast<const char*>(g_mapped_snapshot->data()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 410 *snapshot_data_out = | 415 *snapshot_data_out = |
| 411 reinterpret_cast<const char*>(g_mapped_snapshot->data()); | 416 reinterpret_cast<const char*>(g_mapped_snapshot->data()); |
| 412 *snapshot_size_out = static_cast<int>(g_mapped_snapshot->length()); | 417 *snapshot_size_out = static_cast<int>(g_mapped_snapshot->length()); |
| 413 } else { | 418 } else { |
| 414 *snapshot_data_out = NULL; | 419 *snapshot_data_out = NULL; |
| 415 *snapshot_size_out = 0; | 420 *snapshot_size_out = 0; |
| 416 } | 421 } |
| 417 } | 422 } |
| 418 | 423 |
| 419 } // namespace gin | 424 } // namespace gin |
| OLD | NEW |