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
3 // found in the LICENSE file.
5 #ifndef GIN_INTERCEPTOR_H_
6 #define GIN_INTERCEPTOR_H_
11 #include "base/basictypes.h"
12 #include "gin/gin_export.h"
13 #include "v8/include/v8.h"
19 // Base class for gin::Wrappable-derived classes that want to implement a
20 // property interceptor.
21 class GIN_EXPORT NamedPropertyInterceptor
{
23 NamedPropertyInterceptor(v8::Isolate
* isolate
, WrappableBase
* base
);
24 virtual ~NamedPropertyInterceptor();
26 virtual v8::Local
<v8::Value
> GetNamedProperty(v8::Isolate
* isolate
,
27 const std::string
& property
);
28 virtual void SetNamedProperty(v8::Isolate
* isolate
,
29 const std::string
& property
,
30 v8::Local
<v8::Value
> value
);
31 virtual std::vector
<std::string
> EnumerateNamedProperties(
32 v8::Isolate
* isolate
);
35 v8::Isolate
* isolate_
;
38 DISALLOW_COPY_AND_ASSIGN(NamedPropertyInterceptor
);
41 class GIN_EXPORT IndexedPropertyInterceptor
{
43 IndexedPropertyInterceptor(v8::Isolate
* isolate
, WrappableBase
* base
);
44 virtual ~IndexedPropertyInterceptor();
46 virtual v8::Local
<v8::Value
> GetIndexedProperty(v8::Isolate
* isolate
,
48 virtual void SetIndexedProperty(v8::Isolate
* isolate
,
50 v8::Local
<v8::Value
> value
);
51 virtual std::vector
<uint32_t> EnumerateIndexedProperties(
52 v8::Isolate
* isolate
);
55 v8::Isolate
* isolate_
;
58 DISALLOW_COPY_AND_ASSIGN(IndexedPropertyInterceptor
);
63 #endif // GIN_INTERCEPTOR_H_