| 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/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/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "gin/array_buffer.h" | 14 #include "gin/array_buffer.h" |
| 15 #include "gin/debug_impl.h" | 15 #include "gin/debug_impl.h" |
| 16 #include "gin/event_tracer_impl.h" |
| 16 #include "gin/function_template.h" | 17 #include "gin/function_template.h" |
| 17 #include "gin/per_isolate_data.h" | 18 #include "gin/per_isolate_data.h" |
| 18 #include "gin/public/v8_platform.h" | 19 #include "gin/public/v8_platform.h" |
| 19 #include "gin/run_microtasks_observer.h" | 20 #include "gin/run_microtasks_observer.h" |
| 20 | 21 |
| 21 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 22 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 22 #include "base/files/memory_mapped_file.h" | 23 #include "base/files/memory_mapped_file.h" |
| 23 #include "base/path_service.h" | 24 #include "base/path_service.h" |
| 24 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 25 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 25 | 26 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 natives.compressed_size = g_mapped_natives->length(); | 163 natives.compressed_size = g_mapped_natives->length(); |
| 163 v8::V8::SetNativesDataBlob(&natives); | 164 v8::V8::SetNativesDataBlob(&natives); |
| 164 | 165 |
| 165 v8::StartupData snapshot; | 166 v8::StartupData snapshot; |
| 166 snapshot.data = reinterpret_cast<const char*>(g_mapped_snapshot->data()); | 167 snapshot.data = reinterpret_cast<const char*>(g_mapped_snapshot->data()); |
| 167 snapshot.raw_size = g_mapped_snapshot->length(); | 168 snapshot.raw_size = g_mapped_snapshot->length(); |
| 168 snapshot.compressed_size = g_mapped_snapshot->length(); | 169 snapshot.compressed_size = g_mapped_snapshot->length(); |
| 169 v8::V8::SetSnapshotDataBlob(&snapshot); | 170 v8::V8::SetSnapshotDataBlob(&snapshot); |
| 170 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 171 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 171 v8::V8::Initialize(); | 172 v8::V8::Initialize(); |
| 173 InitV8EventTracer(); |
| 172 v8_is_initialized = true; | 174 v8_is_initialized = true; |
| 173 } | 175 } |
| 174 | 176 |
| 175 void IsolateHolder::AddRunMicrotasksObserver() { | 177 void IsolateHolder::AddRunMicrotasksObserver() { |
| 176 DCHECK(!task_observer_.get()); | 178 DCHECK(!task_observer_.get()); |
| 177 task_observer_.reset(new RunMicrotasksObserver(isolate_));; | 179 task_observer_.reset(new RunMicrotasksObserver(isolate_));; |
| 178 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); | 180 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); |
| 179 } | 181 } |
| 180 | 182 |
| 181 void IsolateHolder::RemoveRunMicrotasksObserver() { | 183 void IsolateHolder::RemoveRunMicrotasksObserver() { |
| 182 DCHECK(task_observer_.get()); | 184 DCHECK(task_observer_.get()); |
| 183 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); | 185 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); |
| 184 task_observer_.reset(); | 186 task_observer_.reset(); |
| 185 } | 187 } |
| 186 | 188 |
| 187 } // namespace gin | 189 } // namespace gin |
| OLD | NEW |