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

Side by Side Diff: gin/per_isolate_data.cc

Issue 194603003: gin: Add the concept of named and indexed interceptors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « gin/per_isolate_data.h ('k') | no next file » | 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 "base/logging.h"
5 #include "gin/per_isolate_data.h" 6 #include "gin/per_isolate_data.h"
6 #include "gin/public/gin_embedders.h" 7 #include "gin/public/gin_embedders.h"
7 8
8 using v8::ArrayBuffer; 9 using v8::ArrayBuffer;
9 using v8::Eternal; 10 using v8::Eternal;
10 using v8::Isolate; 11 using v8::Isolate;
11 using v8::Local; 12 using v8::Local;
12 using v8::Object; 13 using v8::Object;
13 using v8::FunctionTemplate; 14 using v8::FunctionTemplate;
14 using v8::ObjectTemplate; 15 using v8::ObjectTemplate;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 49 }
49 50
50 v8::Local<v8::FunctionTemplate> PerIsolateData::GetFunctionTemplate( 51 v8::Local<v8::FunctionTemplate> PerIsolateData::GetFunctionTemplate(
51 WrapperInfo* info) { 52 WrapperInfo* info) {
52 FunctionTemplateMap::iterator it = function_templates_.find(info); 53 FunctionTemplateMap::iterator it = function_templates_.find(info);
53 if (it == function_templates_.end()) 54 if (it == function_templates_.end())
54 return v8::Local<v8::FunctionTemplate>(); 55 return v8::Local<v8::FunctionTemplate>();
55 return it->second.Get(isolate_); 56 return it->second.Get(isolate_);
56 } 57 }
57 58
59 void PerIsolateData::SetIndexedPropertyInterceptor(
60 WrappableBase* base,
61 IndexedPropertyInterceptor* interceptor) {
62 indexed_interceptors_[base] = interceptor;
63 }
64
65 void PerIsolateData::SetNamedPropertyInterceptor(
66 WrappableBase* base,
67 NamedPropertyInterceptor* interceptor) {
68 named_interceptors_[base] = interceptor;
69 }
70
71 void PerIsolateData::ClearIndexedPropertyInterceptor(
72 WrappableBase* base,
73 IndexedPropertyInterceptor* interceptor) {
74 IndexedPropertyInterceptorMap::iterator it = indexed_interceptors_.find(base);
75 if (it != indexed_interceptors_.end())
76 indexed_interceptors_.erase(it);
77 else
78 NOTREACHED();
79 }
80
81 void PerIsolateData::ClearNamedPropertyInterceptor(
82 WrappableBase* base,
83 NamedPropertyInterceptor* interceptor) {
84 NamedPropertyInterceptorMap::iterator it = named_interceptors_.find(base);
85 if (it != named_interceptors_.end())
86 named_interceptors_.erase(it);
87 else
88 NOTREACHED();
89 }
90
91 IndexedPropertyInterceptor* PerIsolateData::GetIndexedPropertyInterceptor(
92 WrappableBase* base) {
93 IndexedPropertyInterceptorMap::iterator it = indexed_interceptors_.find(base);
94 if (it != indexed_interceptors_.end())
95 return it->second;
96 else
97 return NULL;
98 }
99
100 NamedPropertyInterceptor* PerIsolateData::GetNamedPropertyInterceptor(
101 WrappableBase* base) {
102 NamedPropertyInterceptorMap::iterator it = named_interceptors_.find(base);
103 if (it != named_interceptors_.end())
104 return it->second;
105 else
106 return NULL;
107 }
108
58 } // namespace gin 109 } // namespace gin
OLDNEW
« no previous file with comments | « gin/per_isolate_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698