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

Side by Side Diff: gin/interceptor.h

Issue 467243002: [gin] Allow interceptors to signal whether a they intercepted something (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | « no previous file | gin/interceptor.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 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 #ifndef GIN_INTERCEPTOR_H_ 5 #ifndef GIN_INTERCEPTOR_H_
6 #define GIN_INTERCEPTOR_H_ 6 #define GIN_INTERCEPTOR_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "gin/gin_export.h" 12 #include "gin/gin_export.h"
13 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
14 14
15 namespace gin { 15 namespace gin {
16 16
17 class WrappableBase; 17 class WrappableBase;
18 18
19 // Base class for gin::Wrappable-derived classes that want to implement a 19 // Base class for gin::Wrappable-derived classes that want to implement a
20 // property interceptor. 20 // property interceptor.
21 class GIN_EXPORT NamedPropertyInterceptor { 21 class GIN_EXPORT NamedPropertyInterceptor {
22 public: 22 public:
23 NamedPropertyInterceptor(v8::Isolate* isolate, WrappableBase* base); 23 NamedPropertyInterceptor(v8::Isolate* isolate, WrappableBase* base);
24 virtual ~NamedPropertyInterceptor(); 24 virtual ~NamedPropertyInterceptor();
25 25
26 virtual v8::Local<v8::Value> GetNamedProperty(v8::Isolate* isolate, 26 virtual v8::Local<v8::Value> GetNamedProperty(v8::Isolate* isolate,
27 const std::string& property); 27 const std::string& property);
28 virtual void SetNamedProperty(v8::Isolate* isolate, 28 // Return true if the set was interecepted.
29 virtual bool SetNamedProperty(v8::Isolate* isolate,
29 const std::string& property, 30 const std::string& property,
30 v8::Local<v8::Value> value); 31 v8::Local<v8::Value> value);
31 virtual std::vector<std::string> EnumerateNamedProperties( 32 virtual std::vector<std::string> EnumerateNamedProperties(
32 v8::Isolate* isolate); 33 v8::Isolate* isolate);
33 34
34 private: 35 private:
35 v8::Isolate* isolate_; 36 v8::Isolate* isolate_;
36 WrappableBase* base_; 37 WrappableBase* base_;
37 38
38 DISALLOW_COPY_AND_ASSIGN(NamedPropertyInterceptor); 39 DISALLOW_COPY_AND_ASSIGN(NamedPropertyInterceptor);
39 }; 40 };
40 41
41 class GIN_EXPORT IndexedPropertyInterceptor { 42 class GIN_EXPORT IndexedPropertyInterceptor {
42 public: 43 public:
43 IndexedPropertyInterceptor(v8::Isolate* isolate, WrappableBase* base); 44 IndexedPropertyInterceptor(v8::Isolate* isolate, WrappableBase* base);
44 virtual ~IndexedPropertyInterceptor(); 45 virtual ~IndexedPropertyInterceptor();
45 46
46 virtual v8::Local<v8::Value> GetIndexedProperty(v8::Isolate* isolate, 47 virtual v8::Local<v8::Value> GetIndexedProperty(v8::Isolate* isolate,
47 uint32_t index); 48 uint32_t index);
48 virtual void SetIndexedProperty(v8::Isolate* isolate, 49 // Return true if the set was interecepted.
50 virtual bool SetIndexedProperty(v8::Isolate* isolate,
49 uint32_t index, 51 uint32_t index,
50 v8::Local<v8::Value> value); 52 v8::Local<v8::Value> value);
51 virtual std::vector<uint32_t> EnumerateIndexedProperties( 53 virtual std::vector<uint32_t> EnumerateIndexedProperties(
52 v8::Isolate* isolate); 54 v8::Isolate* isolate);
53 55
54 private: 56 private:
55 v8::Isolate* isolate_; 57 v8::Isolate* isolate_;
56 WrappableBase* base_; 58 WrappableBase* base_;
57 59
58 DISALLOW_COPY_AND_ASSIGN(IndexedPropertyInterceptor); 60 DISALLOW_COPY_AND_ASSIGN(IndexedPropertyInterceptor);
59 }; 61 };
60 62
61 } // namespace gin 63 } // namespace gin
62 64
63 #endif // GIN_INTERCEPTOR_H_ 65 #endif // GIN_INTERCEPTOR_H_
OLDNEW
« no previous file with comments | « no previous file | gin/interceptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698