Revert "[M120 Migration]Fix for crash during chrome exit"
[platform/framework/web/chromium-efl.git] / gin / interceptor.h
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GIN_INTERCEPTOR_H_
6 #define GIN_INTERCEPTOR_H_
7
8 #include <stdint.h>
9
10 #include <string>
11 #include <vector>
12
13 #include "base/memory/raw_ptr.h"
14 #include "gin/gin_export.h"
15 #include "v8/include/v8-forward.h"
16
17 namespace gin {
18
19 class WrappableBase;
20
21 // Base class for gin::Wrappable-derived classes that want to implement a
22 // property interceptor.
23 class GIN_EXPORT NamedPropertyInterceptor {
24  public:
25   NamedPropertyInterceptor(v8::Isolate* isolate, WrappableBase* base);
26   NamedPropertyInterceptor(const NamedPropertyInterceptor&) = delete;
27   NamedPropertyInterceptor& operator=(const NamedPropertyInterceptor&) = delete;
28   virtual ~NamedPropertyInterceptor();
29
30   virtual v8::Local<v8::Value> GetNamedProperty(v8::Isolate* isolate,
31                                                 const std::string& property);
32   // Return true if the set was interecepted.
33   virtual bool SetNamedProperty(v8::Isolate* isolate,
34                                 const std::string& property,
35                                 v8::Local<v8::Value> value);
36   virtual std::vector<std::string> EnumerateNamedProperties(
37       v8::Isolate* isolate);
38
39  private:
40   raw_ptr<v8::Isolate, LeakedDanglingUntriaged> isolate_;
41   raw_ptr<WrappableBase> base_;
42 };
43
44 class GIN_EXPORT IndexedPropertyInterceptor {
45  public:
46   IndexedPropertyInterceptor(v8::Isolate* isolate, WrappableBase* base);
47   IndexedPropertyInterceptor(const IndexedPropertyInterceptor&) = delete;
48   IndexedPropertyInterceptor& operator=(const IndexedPropertyInterceptor&) =
49       delete;
50   virtual ~IndexedPropertyInterceptor();
51
52   virtual v8::Local<v8::Value> GetIndexedProperty(v8::Isolate* isolate,
53                                                   uint32_t index);
54   // Return true if the set was interecepted.
55   virtual bool SetIndexedProperty(v8::Isolate* isolate,
56                                   uint32_t index,
57                                   v8::Local<v8::Value> value);
58   virtual std::vector<uint32_t> EnumerateIndexedProperties(
59       v8::Isolate* isolate);
60
61  private:
62   raw_ptr<v8::Isolate, LeakedDanglingUntriaged> isolate_;
63   raw_ptr<WrappableBase> base_;
64 };
65
66 }  // namespace gin
67
68 #endif  // GIN_INTERCEPTOR_H_