OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "bindings/core/v8/V8ScriptRunner.h" | 41 #include "bindings/core/v8/V8ScriptRunner.h" |
42 #include "bindings/core/v8/V8Window.h" | 42 #include "bindings/core/v8/V8Window.h" |
43 #include "core/frame/LocalDOMWindow.h" | 43 #include "core/frame/LocalDOMWindow.h" |
44 #include "core/inspector/InjectedScriptHost.h" | 44 #include "core/inspector/InjectedScriptHost.h" |
45 #include "wtf/RefPtr.h" | 45 #include "wtf/RefPtr.h" |
46 | 46 |
47 namespace blink { | 47 namespace blink { |
48 | 48 |
49 struct InjectedScriptManager::CallbackData { | 49 struct InjectedScriptManager::CallbackData { |
50 ScopedPersistent<v8::Object> handle; | 50 ScopedPersistent<v8::Object> handle; |
51 RefPtr<InjectedScriptHost> host; | 51 RefPtrWillBePersistent<InjectedScriptHost> host; |
52 }; | 52 }; |
53 | 53 |
54 static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHos
t* host, v8::Isolate* isolate) | 54 static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHos
t* host, v8::Isolate* isolate) |
55 { | 55 { |
56 v8::Local<v8::Function> function = V8InjectedScriptHost::domTemplate(isolate
)->GetFunction(); | 56 v8::Local<v8::Function> function = V8InjectedScriptHost::domTemplate(isolate
)->GetFunction(); |
57 if (function.IsEmpty()) { | 57 if (function.IsEmpty()) { |
58 // Return if allocation failed. | 58 // Return if allocation failed. |
59 return v8::Local<v8::Object>(); | 59 return v8::Local<v8::Object>(); |
60 } | 60 } |
61 v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(is
olate, function); | 61 v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(is
olate, function); |
62 if (instanceTemplate.IsEmpty()) { | 62 if (instanceTemplate.IsEmpty()) { |
63 // Avoid setting the wrapper if allocation failed. | 63 // Avoid setting the wrapper if allocation failed. |
64 return v8::Local<v8::Object>(); | 64 return v8::Local<v8::Object>(); |
65 } | 65 } |
| 66 #if ENABLE(OILPAN) |
| 67 V8DOMWrapper::setNativeInfoWithPersistentHandle(instanceTemplate, &V8Injecte
dScriptHost::wrapperTypeInfo, host, new Persistent<InjectedScriptHost>(host)); |
| 68 #else |
66 V8DOMWrapper::setNativeInfo(instanceTemplate, &V8InjectedScriptHost::wrapper
TypeInfo, host); | 69 V8DOMWrapper::setNativeInfo(instanceTemplate, &V8InjectedScriptHost::wrapper
TypeInfo, host); |
| 70 #endif |
67 // Create a weak reference to the v8 wrapper of InspectorBackend to deref | 71 // Create a weak reference to the v8 wrapper of InspectorBackend to deref |
68 // InspectorBackend when the wrapper is garbage collected. | 72 // InspectorBackend when the wrapper is garbage collected. |
69 InjectedScriptManager::CallbackData* data = new InjectedScriptManager::Callb
ackData; | 73 InjectedScriptManager::CallbackData* data = new InjectedScriptManager::Callb
ackData; |
70 data->host = host; | 74 data->host = host; |
71 data->handle.set(isolate, instanceTemplate); | 75 data->handle.set(isolate, instanceTemplate); |
72 data->handle.setWeak(data, &InjectedScriptManager::setWeakCallback); | 76 data->handle.setWeak(data, &InjectedScriptManager::setWeakCallback); |
73 return instanceTemplate; | 77 return instanceTemplate; |
74 } | 78 } |
75 | 79 |
76 ScriptValue InjectedScriptManager::createInjectedScript(const String& scriptSour
ce, ScriptState* inspectedScriptState, int id) | 80 ScriptValue InjectedScriptManager::createInjectedScript(const String& scriptSour
ce, ScriptState* inspectedScriptState, int id) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 120 } |
117 | 121 |
118 void InjectedScriptManager::setWeakCallback(const v8::WeakCallbackData<v8::Objec
t, InjectedScriptManager::CallbackData>& data) | 122 void InjectedScriptManager::setWeakCallback(const v8::WeakCallbackData<v8::Objec
t, InjectedScriptManager::CallbackData>& data) |
119 { | 123 { |
120 data.GetParameter()->handle.clear(); | 124 data.GetParameter()->handle.clear(); |
121 data.GetParameter()->host.clear(); | 125 data.GetParameter()->host.clear(); |
122 delete data.GetParameter(); | 126 delete data.GetParameter(); |
123 } | 127 } |
124 | 128 |
125 } // namespace blink | 129 } // namespace blink |
OLD | NEW |