| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/logging.h" |
| 6 #include "gin/arguments.h" | 6 #include "gin/arguments.h" |
| 7 #include "gin/handle.h" | 7 #include "gin/handle.h" |
| 8 #include "gin/interceptor.h" | 8 #include "gin/interceptor.h" |
| 9 #include "gin/object_template_builder.h" | 9 #include "gin/object_template_builder.h" |
| 10 #include "gin/per_isolate_data.h" | 10 #include "gin/per_isolate_data.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (!function_template.IsEmpty()) | 111 if (!function_template.IsEmpty()) |
| 112 return function_template; | 112 return function_template; |
| 113 function_template = CreateFunctionTemplate( | 113 function_template = CreateFunctionTemplate( |
| 114 isolate, base::Bind(&MyInterceptor::Call), HolderIsFirstArgument); | 114 isolate, base::Bind(&MyInterceptor::Call), HolderIsFirstArgument); |
| 115 template_cache_.Set(name, function_template); | 115 template_cache_.Set(name, function_template); |
| 116 return function_template; | 116 return function_template; |
| 117 } | 117 } |
| 118 | 118 |
| 119 int value_; | 119 int value_; |
| 120 | 120 |
| 121 v8::StdPersistentValueMap<std::string, v8::FunctionTemplate> template_cache_; | 121 v8::StdGlobalValueMap<std::string, v8::FunctionTemplate> template_cache_; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(MyInterceptor); | 123 DISALLOW_COPY_AND_ASSIGN(MyInterceptor); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 WrapperInfo MyInterceptor::kWrapperInfo = {kEmbedderNativeGin}; | 126 WrapperInfo MyInterceptor::kWrapperInfo = {kEmbedderNativeGin}; |
| 127 | 127 |
| 128 class InterceptorTest : public V8Test { | 128 class InterceptorTest : public V8Test { |
| 129 public: | 129 public: |
| 130 void RunInterceptorTest(const std::string& script_source) { | 130 void RunInterceptorTest(const std::string& script_source) { |
| 131 v8::Isolate* isolate = instance_->isolate(); | 131 v8::Isolate* isolate = instance_->isolate(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 TEST_F(InterceptorTest, BypassInterceptorForbidden) { | 187 TEST_F(InterceptorTest, BypassInterceptorForbidden) { |
| 188 RunInterceptorTest( | 188 RunInterceptorTest( |
| 189 "(function (obj) {" | 189 "(function (obj) {" |
| 190 " obj.value = 191 /* make test happy */;" | 190 " obj.value = 191 /* make test happy */;" |
| 191 " obj[1] = 23;" | 191 " obj[1] = 23;" |
| 192 " if (obj[1] === 23) throw 'FAIL'; })"); | 192 " if (obj[1] === 23) throw 'FAIL'; })"); |
| 193 } | 193 } |
| 194 | 194 |
| 195 } // namespace gin | 195 } // namespace gin |
| OLD | NEW |