Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: gin/isolate_holder.cc

Issue 1100743004: Adding field to tell if gin::IsolateHolder needs lock to be accessed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@discardable
Patch Set: Adding explicit. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gin/public/isolate_holder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/sys_info.h" 12 #include "base/sys_info.h"
13 #include "gin/debug_impl.h" 13 #include "gin/debug_impl.h"
14 #include "gin/function_template.h" 14 #include "gin/function_template.h"
15 #include "gin/per_isolate_data.h" 15 #include "gin/per_isolate_data.h"
16 #include "gin/run_microtasks_observer.h" 16 #include "gin/run_microtasks_observer.h"
17 #include "gin/v8_initializer.h" 17 #include "gin/v8_initializer.h"
18 18
19 namespace gin { 19 namespace gin {
20 20
21 namespace { 21 namespace {
22 v8::ArrayBuffer::Allocator* g_array_buffer_allocator = nullptr; 22 v8::ArrayBuffer::Allocator* g_array_buffer_allocator = nullptr;
23 } // namespace 23 } // namespace
24 24
25 IsolateHolder::IsolateHolder() { 25 IsolateHolder::IsolateHolder() : IsolateHolder(AccessMode::kSingleThread) {
26 }
27
28 IsolateHolder::IsolateHolder(AccessMode access_mode)
29 : access_mode_(access_mode) {
26 v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator; 30 v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator;
27 CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first"; 31 CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first";
28 v8::Isolate::CreateParams params; 32 v8::Isolate::CreateParams params;
29 params.entry_hook = DebugImpl::GetFunctionEntryHook(); 33 params.entry_hook = DebugImpl::GetFunctionEntryHook();
30 params.code_event_handler = DebugImpl::GetJitCodeEventHandler(); 34 params.code_event_handler = DebugImpl::GetJitCodeEventHandler();
31 params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), 35 params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
32 base::SysInfo::AmountOfVirtualMemory()); 36 base::SysInfo::AmountOfVirtualMemory());
33 isolate_ = v8::Isolate::New(params); 37 isolate_ = v8::Isolate::New(params);
34 isolate_data_.reset(new PerIsolateData(isolate_, allocator)); 38 isolate_data_.reset(new PerIsolateData(isolate_, allocator));
35 #if defined(OS_WIN) 39 #if defined(OS_WIN)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); 82 base::MessageLoop::current()->AddTaskObserver(task_observer_.get());
79 } 83 }
80 84
81 void IsolateHolder::RemoveRunMicrotasksObserver() { 85 void IsolateHolder::RemoveRunMicrotasksObserver() {
82 DCHECK(task_observer_.get()); 86 DCHECK(task_observer_.get());
83 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); 87 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get());
84 task_observer_.reset(); 88 task_observer_.reset();
85 } 89 }
86 90
87 } // namespace gin 91 } // namespace gin
OLDNEW
« no previous file with comments | « no previous file | gin/public/isolate_holder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698