| 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 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/inspector/InjectedScriptNative.h" | 7 #include "core/inspector/InjectedScriptNative.h" |
| 8 | 8 |
| 9 #include "bindings/core/v8/V8HiddenValue.h" | 9 #include "bindings/core/v8/V8HiddenValue.h" |
| 10 #include "platform/JSONValues.h" | 10 #include "platform/JSONValues.h" |
| 11 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
| 12 #include "wtf/text/WTFString.h" | 12 #include "wtf/text/WTFString.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 InjectedScriptNative::InjectedScriptNative(v8::Isolate* isolate) | 16 InjectedScriptNative::InjectedScriptNative(v8::Isolate* isolate) |
| 17 : m_lastBoundObjectId(1) | 17 : m_lastBoundObjectId(1) |
| 18 , m_isolate(isolate) | 18 , m_isolate(isolate) |
| 19 , m_idToWrappedObject(m_isolate) | 19 , m_idToWrappedObject(m_isolate) |
| 20 { | 20 { |
| 21 } | 21 } |
| 22 | 22 |
| 23 InjectedScriptNative::~InjectedScriptNative() { } | 23 InjectedScriptNative::~InjectedScriptNative() { } |
| 24 | 24 |
| 25 void InjectedScriptNative::setOnInjectedScriptHost(v8::Handle<v8::Object> inject
edScriptHost) | 25 void InjectedScriptNative::setOnInjectedScriptHost(v8::Local<v8::Object> injecte
dScriptHost) |
| 26 { | 26 { |
| 27 v8::HandleScope handleScope(m_isolate); | 27 v8::HandleScope handleScope(m_isolate); |
| 28 v8::Handle<v8::External> external = v8::External::New(m_isolate, this); | 28 v8::Local<v8::External> external = v8::External::New(m_isolate, this); |
| 29 V8HiddenValue::setHiddenValue(m_isolate, injectedScriptHost, V8HiddenValue::
injectedScriptNative(m_isolate), external); | 29 V8HiddenValue::setHiddenValue(m_isolate, injectedScriptHost, V8HiddenValue::
injectedScriptNative(m_isolate), external); |
| 30 } | 30 } |
| 31 | 31 |
| 32 InjectedScriptNative* InjectedScriptNative::fromInjectedScriptHost(v8::Handle<v8
::Object> injectedScriptObject) | 32 InjectedScriptNative* InjectedScriptNative::fromInjectedScriptHost(v8::Local<v8:
:Object> injectedScriptObject) |
| 33 { | 33 { |
| 34 v8::Isolate* isolate = injectedScriptObject->GetIsolate(); | 34 v8::Isolate* isolate = injectedScriptObject->GetIsolate(); |
| 35 v8::HandleScope handleScope(isolate); | 35 v8::HandleScope handleScope(isolate); |
| 36 v8::Handle<v8::Value> value = V8HiddenValue::getHiddenValue(isolate, injecte
dScriptObject, V8HiddenValue::injectedScriptNative(isolate)); | 36 v8::Local<v8::Value> value = V8HiddenValue::getHiddenValue(isolate, injected
ScriptObject, V8HiddenValue::injectedScriptNative(isolate)); |
| 37 ASSERT(!value.IsEmpty()); | 37 ASSERT(!value.IsEmpty()); |
| 38 v8::Handle<v8::External> external = value.As<v8::External>(); | 38 v8::Local<v8::External> external = value.As<v8::External>(); |
| 39 void* ptr = external->Value(); | 39 void* ptr = external->Value(); |
| 40 ASSERT(ptr); | 40 ASSERT(ptr); |
| 41 return static_cast<InjectedScriptNative*>(ptr); | 41 return static_cast<InjectedScriptNative*>(ptr); |
| 42 } | 42 } |
| 43 | 43 |
| 44 int InjectedScriptNative::bind(v8::Local<v8::Value> value, const String& groupNa
me) | 44 int InjectedScriptNative::bind(v8::Local<v8::Value> value, const String& groupNa
me) |
| 45 { | 45 { |
| 46 if (m_lastBoundObjectId <= 0) | 46 if (m_lastBoundObjectId <= 0) |
| 47 m_lastBoundObjectId = 1; | 47 m_lastBoundObjectId = 1; |
| 48 int id = m_lastBoundObjectId++; | 48 int id = m_lastBoundObjectId++; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 String InjectedScriptNative::groupName(int objectId) const | 91 String InjectedScriptNative::groupName(int objectId) const |
| 92 { | 92 { |
| 93 if (objectId <= 0) | 93 if (objectId <= 0) |
| 94 return String(); | 94 return String(); |
| 95 return m_idToObjectGroupName.get(objectId); | 95 return m_idToObjectGroupName.get(objectId); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace blink | 98 } // namespace blink |
| 99 | 99 |
| OLD | NEW |