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

Side by Side Diff: gin/per_isolate_data.h

Issue 2478813002: When an Isolate is configured to use lockers, foreground tasks need to lock (Closed)
Patch Set: updates Created 4 years, 1 month 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 | « gin/isolate_holder.cc ('k') | gin/per_isolate_data.cc » ('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 #ifndef GIN_PER_ISOLATE_DATA_H_ 5 #ifndef GIN_PER_ISOLATE_DATA_H_
6 #define GIN_PER_ISOLATE_DATA_H_ 6 #define GIN_PER_ISOLATE_DATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "gin/gin_export.h" 13 #include "gin/gin_export.h"
14 #include "gin/public/isolate_holder.h"
14 #include "gin/public/v8_idle_task_runner.h" 15 #include "gin/public/v8_idle_task_runner.h"
15 #include "gin/public/wrapper_info.h" 16 #include "gin/public/wrapper_info.h"
16 #include "v8/include/v8.h" 17 #include "v8/include/v8.h"
17 18
18 namespace base { 19 namespace base {
19 class SingleThreadTaskRunner; 20 class SingleThreadTaskRunner;
20 } 21 }
21 22
22 namespace gin { 23 namespace gin {
23 24
24 class IndexedPropertyInterceptor; 25 class IndexedPropertyInterceptor;
25 class NamedPropertyInterceptor; 26 class NamedPropertyInterceptor;
26 class WrappableBase; 27 class WrappableBase;
27 28
28 // There is one instance of PerIsolateData per v8::Isolate managed by Gin. This 29 // There is one instance of PerIsolateData per v8::Isolate managed by Gin. This
29 // class stores all the Gin-related data that varies per isolate. 30 // class stores all the Gin-related data that varies per isolate.
30 class GIN_EXPORT PerIsolateData { 31 class GIN_EXPORT PerIsolateData {
31 public: 32 public:
32 PerIsolateData(v8::Isolate* isolate, v8::ArrayBuffer::Allocator* allocator); 33 PerIsolateData(v8::Isolate* isolate,
34 v8::ArrayBuffer::Allocator* allocator,
35 IsolateHolder::AccessMode access_mode);
33 ~PerIsolateData(); 36 ~PerIsolateData();
34 37
35 static PerIsolateData* From(v8::Isolate* isolate); 38 static PerIsolateData* From(v8::Isolate* isolate);
36 39
37 // Each isolate is associated with a collection of v8::ObjectTemplates and 40 // Each isolate is associated with a collection of v8::ObjectTemplates and
38 // v8::FunctionTemplates. Typically these template objects are created 41 // v8::FunctionTemplates. Typically these template objects are created
39 // lazily. 42 // lazily.
40 void SetObjectTemplate(WrapperInfo* info, 43 void SetObjectTemplate(WrapperInfo* info,
41 v8::Local<v8::ObjectTemplate> object_template); 44 v8::Local<v8::ObjectTemplate> object_template);
42 void SetFunctionTemplate(WrapperInfo* info, 45 void SetFunctionTemplate(WrapperInfo* info,
(...skipping 24 matching lines...) Expand all
67 70
68 void EnableIdleTasks(std::unique_ptr<V8IdleTaskRunner> idle_task_runner); 71 void EnableIdleTasks(std::unique_ptr<V8IdleTaskRunner> idle_task_runner);
69 72
70 v8::Isolate* isolate() { return isolate_; } 73 v8::Isolate* isolate() { return isolate_; }
71 v8::ArrayBuffer::Allocator* allocator() { return allocator_; } 74 v8::ArrayBuffer::Allocator* allocator() { return allocator_; }
72 base::SingleThreadTaskRunner* task_runner() { return task_runner_.get(); } 75 base::SingleThreadTaskRunner* task_runner() { return task_runner_.get(); }
73 V8IdleTaskRunner* idle_task_runner() { 76 V8IdleTaskRunner* idle_task_runner() {
74 return idle_task_runner_.get(); 77 return idle_task_runner_.get();
75 } 78 }
76 79
80 IsolateHolder::AccessMode access_mode() const { return access_mode_; }
81
77 private: 82 private:
78 typedef std::map< 83 typedef std::map<
79 WrapperInfo*, v8::Eternal<v8::ObjectTemplate> > ObjectTemplateMap; 84 WrapperInfo*, v8::Eternal<v8::ObjectTemplate> > ObjectTemplateMap;
80 typedef std::map< 85 typedef std::map<
81 WrapperInfo*, v8::Eternal<v8::FunctionTemplate> > FunctionTemplateMap; 86 WrapperInfo*, v8::Eternal<v8::FunctionTemplate> > FunctionTemplateMap;
82 typedef std::map<WrappableBase*, IndexedPropertyInterceptor*> 87 typedef std::map<WrappableBase*, IndexedPropertyInterceptor*>
83 IndexedPropertyInterceptorMap; 88 IndexedPropertyInterceptorMap;
84 typedef std::map<WrappableBase*, NamedPropertyInterceptor*> 89 typedef std::map<WrappableBase*, NamedPropertyInterceptor*>
85 NamedPropertyInterceptorMap; 90 NamedPropertyInterceptorMap;
86 91
87 // PerIsolateData doesn't actually own |isolate_|. Instead, the isolate is 92 // PerIsolateData doesn't actually own |isolate_|. Instead, the isolate is
88 // owned by the IsolateHolder, which also owns the PerIsolateData. 93 // owned by the IsolateHolder, which also owns the PerIsolateData.
89 v8::Isolate* isolate_; 94 v8::Isolate* isolate_;
90 v8::ArrayBuffer::Allocator* allocator_; 95 v8::ArrayBuffer::Allocator* allocator_;
96 IsolateHolder::AccessMode access_mode_;
91 ObjectTemplateMap object_templates_; 97 ObjectTemplateMap object_templates_;
92 FunctionTemplateMap function_templates_; 98 FunctionTemplateMap function_templates_;
93 IndexedPropertyInterceptorMap indexed_interceptors_; 99 IndexedPropertyInterceptorMap indexed_interceptors_;
94 NamedPropertyInterceptorMap named_interceptors_; 100 NamedPropertyInterceptorMap named_interceptors_;
95 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 101 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
96 std::unique_ptr<V8IdleTaskRunner> idle_task_runner_; 102 std::unique_ptr<V8IdleTaskRunner> idle_task_runner_;
97 103
98 DISALLOW_COPY_AND_ASSIGN(PerIsolateData); 104 DISALLOW_COPY_AND_ASSIGN(PerIsolateData);
99 }; 105 };
100 106
101 } // namespace gin 107 } // namespace gin
102 108
103 #endif // GIN_PER_ISOLATE_DATA_H_ 109 #endif // GIN_PER_ISOLATE_DATA_H_
OLDNEW
« no previous file with comments | « gin/isolate_holder.cc ('k') | gin/per_isolate_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698