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 #ifndef EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ | 5 #ifndef EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ |
6 #define EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ | 6 #define EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "extensions/renderer/native_handler.h" | 13 #include "extensions/renderer/native_handler.h" |
14 #include "extensions/renderer/scoped_persistent.h" | |
15 #include "v8/include/v8-util.h" | 14 #include "v8/include/v8-util.h" |
16 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
17 | 16 |
18 namespace extensions { | 17 namespace extensions { |
19 class ScriptContext; | 18 class ScriptContext; |
20 | 19 |
21 // An ObjectBackedNativeHandler is a factory for JS objects with functions on | 20 // An ObjectBackedNativeHandler is a factory for JS objects with functions on |
22 // them that map to native C++ functions. Subclasses should call RouteFunction() | 21 // them that map to native C++ functions. Subclasses should call RouteFunction() |
23 // in their constructor to define functions on the created JS objects. | 22 // in their constructor to define functions on the created JS objects. |
24 class ObjectBackedNativeHandler : public NativeHandler { | 23 class ObjectBackedNativeHandler : public NativeHandler { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // contentWindow of an iframe after it's removed. | 61 // contentWindow of an iframe after it's removed. |
63 // | 62 // |
64 // So, we use v8::Objects here to hold that data, effectively refcounting | 63 // So, we use v8::Objects here to hold that data, effectively refcounting |
65 // the data. When |this| is destroyed we remove the base::Bound function from | 64 // the data. When |this| is destroyed we remove the base::Bound function from |
66 // the object to indicate that it shoudn't be called. | 65 // the object to indicate that it shoudn't be called. |
67 typedef v8::PersistentValueVector<v8::Object> RouterData; | 66 typedef v8::PersistentValueVector<v8::Object> RouterData; |
68 RouterData router_data_; | 67 RouterData router_data_; |
69 | 68 |
70 ScriptContext* context_; | 69 ScriptContext* context_; |
71 | 70 |
72 ScopedPersistent<v8::ObjectTemplate> object_template_; | 71 v8::UniquePersistent<v8::ObjectTemplate> object_template_; |
73 | 72 |
74 DISALLOW_COPY_AND_ASSIGN(ObjectBackedNativeHandler); | 73 DISALLOW_COPY_AND_ASSIGN(ObjectBackedNativeHandler); |
75 }; | 74 }; |
76 | 75 |
77 } // namespace extensions | 76 } // namespace extensions |
78 | 77 |
79 #endif // EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ | 78 #endif // EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ |
OLD | NEW |