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

Side by Side Diff: Source/bindings/core/v8/custom/V8InjectedScriptManager.cpp

Issue 1040703002: Oilpan: avoid InjectedScriptManager::CallbackData-induced leaks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add explicit dispose() Created 5 years, 9 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
« no previous file with comments | « no previous file | Source/core/inspector/InjectedScriptManager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 "core/inspector/InjectedScriptNative.h" 45 #include "core/inspector/InjectedScriptNative.h"
46 #include "wtf/RefPtr.h" 46 #include "wtf/RefPtr.h"
47 47
48 namespace blink { 48 namespace blink {
49 49
50 InjectedScriptManager::CallbackData* InjectedScriptManager::createCallbackData(I njectedScriptManager* injectedScriptManager) 50 InjectedScriptManager::CallbackData* InjectedScriptManager::createCallbackData(I njectedScriptManager* injectedScriptManager)
51 { 51 {
52 OwnPtr<InjectedScriptManager::CallbackData> callbackData = adoptPtr(new Inje ctedScriptManager::CallbackData()); 52 OwnPtrWillBeRawPtr<InjectedScriptManager::CallbackData> callbackData = Injec tedScriptManager::CallbackData::create(injectedScriptManager);
53 InjectedScriptManager::CallbackData* callbackDataPtr = callbackData.get(); 53 InjectedScriptManager::CallbackData* callbackDataPtr = callbackData.get();
54 callbackData->injectedScriptManager = injectedScriptManager;
55 m_callbackDataSet.add(callbackData.release()); 54 m_callbackDataSet.add(callbackData.release());
56 return callbackDataPtr; 55 return callbackDataPtr;
57 } 56 }
58 57
59 void InjectedScriptManager::removeCallbackData(InjectedScriptManager::CallbackDa ta* callbackData) 58 void InjectedScriptManager::removeCallbackData(InjectedScriptManager::CallbackDa ta* callbackData)
60 { 59 {
61 ASSERT(m_callbackDataSet.contains(callbackData)); 60 ASSERT(m_callbackDataSet.contains(callbackData));
61 callbackData->dispose();
62 m_callbackDataSet.remove(callbackData); 62 m_callbackDataSet.remove(callbackData);
63 } 63 }
64 64
65 static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(PassRefPtrWillBeR awPtr<InjectedScriptHost> host, InjectedScriptManager* injectedScriptManager, v8 ::Local<v8::Object> creationContext, v8::Isolate* isolate) 65 static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(PassRefPtrWillBeR awPtr<InjectedScriptHost> host, InjectedScriptManager* injectedScriptManager, v8 ::Local<v8::Object> creationContext, v8::Isolate* isolate)
66 { 66 {
67 ASSERT(host); 67 ASSERT(host);
68 68
69 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio nContext, &V8InjectedScriptHost::wrapperTypeInfo, host.get()); 69 v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creatio nContext, &V8InjectedScriptHost::wrapperTypeInfo, host.get());
70 if (UNLIKELY(wrapper.IsEmpty())) 70 if (UNLIKELY(wrapper.IsEmpty()))
71 return wrapper; 71 return wrapper;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return BindingSecurity::shouldAllowAccessToFrame(scriptState->isolate(), fra me, DoNotReportSecurityError); 127 return BindingSecurity::shouldAllowAccessToFrame(scriptState->isolate(), fra me, DoNotReportSecurityError);
128 } 128 }
129 129
130 void InjectedScriptManager::setWeakCallback(const v8::WeakCallbackData<v8::Objec t, InjectedScriptManager::CallbackData>& data) 130 void InjectedScriptManager::setWeakCallback(const v8::WeakCallbackData<v8::Objec t, InjectedScriptManager::CallbackData>& data)
131 { 131 {
132 InjectedScriptManager::CallbackData* callbackData = data.GetParameter(); 132 InjectedScriptManager::CallbackData* callbackData = data.GetParameter();
133 callbackData->injectedScriptManager->removeCallbackData(callbackData); 133 callbackData->injectedScriptManager->removeCallbackData(callbackData);
134 } 134 }
135 135
136 } // namespace blink 136 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/inspector/InjectedScriptManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698