OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 InjectedScriptNative_h | 5 #ifndef InjectedScriptNative_h |
6 #define InjectedScriptNative_h | 6 #define InjectedScriptNative_h |
7 | 7 |
8 #include "platform/inspector_protocol/Collections.h" | 8 #include "platform/inspector_protocol/Collections.h" |
9 #include "platform/inspector_protocol/Platform.h" | 9 #include "platform/inspector_protocol/Platform.h" |
10 #include "platform/inspector_protocol/String16.h" | 10 #include "platform/inspector_protocol/String16.h" |
11 #include <v8.h> | 11 #include <v8.h> |
12 | 12 |
| 13 #include <vector> |
| 14 |
13 namespace blink { | 15 namespace blink { |
14 | 16 |
15 class InjectedScriptNative final { | 17 class InjectedScriptNative final { |
16 public: | 18 public: |
17 explicit InjectedScriptNative(v8::Isolate*); | 19 explicit InjectedScriptNative(v8::Isolate*); |
18 ~InjectedScriptNative(); | 20 ~InjectedScriptNative(); |
19 | 21 |
20 void setOnInjectedScriptHost(v8::Local<v8::Object>); | 22 void setOnInjectedScriptHost(v8::Local<v8::Object>); |
21 static InjectedScriptNative* fromInjectedScriptHost(v8::Local<v8::Object>); | 23 static InjectedScriptNative* fromInjectedScriptHost(v8::Local<v8::Object>); |
22 | 24 |
23 int bind(v8::Local<v8::Value>, const String16& groupName); | 25 int bind(v8::Local<v8::Value>, const String16& groupName); |
24 void unbind(int id); | 26 void unbind(int id); |
25 v8::Local<v8::Value> objectForId(int id); | 27 v8::Local<v8::Value> objectForId(int id); |
26 | 28 |
27 void releaseObjectGroup(const String16& groupName); | 29 void releaseObjectGroup(const String16& groupName); |
28 String16 groupName(int objectId) const; | 30 String16 groupName(int objectId) const; |
29 | 31 |
30 private: | 32 private: |
31 void addObjectToGroup(int objectId, const String16& groupName); | 33 void addObjectToGroup(int objectId, const String16& groupName); |
32 | 34 |
33 int m_lastBoundObjectId; | 35 int m_lastBoundObjectId; |
34 v8::Isolate* m_isolate; | 36 v8::Isolate* m_isolate; |
35 protocol::HashMap<int, std::unique_ptr<v8::Global<v8::Value>>> m_idToWrapped
Object; | 37 protocol::HashMap<int, std::unique_ptr<v8::Global<v8::Value>>> m_idToWrapped
Object; |
36 typedef protocol::HashMap<int, String16> IdToObjectGroupName; | 38 typedef protocol::HashMap<int, String16> IdToObjectGroupName; |
37 IdToObjectGroupName m_idToObjectGroupName; | 39 IdToObjectGroupName m_idToObjectGroupName; |
38 typedef protocol::HashMap<String16, protocol::Vector<int>> NameToObjectGroup
; | 40 typedef protocol::HashMap<String16, std::vector<int>> NameToObjectGroup; |
39 NameToObjectGroup m_nameToObjectGroup; | 41 NameToObjectGroup m_nameToObjectGroup; |
40 }; | 42 }; |
41 | 43 |
42 } // namespace blink | 44 } // namespace blink |
43 | 45 |
44 #endif | 46 #endif |
OLD | NEW |