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

Unified Diff: third_party/WebKit/Source/web/WebPluginContainerImpl.cpp

Issue 1442643003: Oilpan: move WebPluginLoadObserver to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: non-oilpan compile fix Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp b/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
index 72629f332e487324fae1cc8a508400a567b45c9e..6e90a18242f83d8d9ffdab6f898df266a795b422 100644
--- a/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
+++ b/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
@@ -497,9 +497,12 @@ void WebPluginContainerImpl::loadFrameRequest(const WebURLRequest& request, cons
// FIXME: This is a bit of hack to allow us to observe completion of
// our frame request. It would be better to evolve FrameLoader to
// support a completion callback instead.
- OwnPtr<WebPluginLoadObserver> observer = adoptPtr(new WebPluginLoadObserver(this, request.url(), notifyData));
- // FIXME: Calling get here is dangerous! What if observer is freed?
+ OwnPtrWillBeRawPtr<WebPluginLoadObserver> observer = WebPluginLoadObserver::create(this, request.url(), notifyData);
+#if ENABLE(OILPAN)
+ m_pluginLoadObservers.add(observer);
+#else
m_pluginLoadObservers.append(observer.get());
+#endif
WebDataSourceImpl::setNextPluginLoadObserver(observer.release());
}
@@ -681,10 +684,17 @@ bool WebPluginContainerImpl::wantsWheelEvents()
void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver* observer)
{
+#if ENABLE(OILPAN)
+ auto it = m_pluginLoadObservers.find(observer);
+ if (it != m_pluginLoadObservers.end())
+ return;
+ m_pluginLoadObservers.remove(it);
+#else
size_t pos = m_pluginLoadObservers.find(observer);
if (pos == kNotFound)
return;
m_pluginLoadObservers.remove(pos);
+#endif
}
// Private methods -------------------------------------------------------------
@@ -722,21 +732,33 @@ void WebPluginContainerImpl::dispose()
if (m_element && m_touchEventRequestType != TouchEventRequestTypeNone && m_element->document().frameHost())
m_element->document().frameHost()->eventHandlerRegistry().didRemoveEventHandler(*m_element, EventHandlerRegistry::TouchEvent);
- for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i)
- m_pluginLoadObservers[i]->clearPluginContainer();
+#if ENABLE(OILPAN)
+ if (!m_shouldDisposePlugin) {
+ for (const auto& observer : m_pluginLoadObservers)
+ observer->clearPluginContainer();
+ }
+#else
+ for (const auto& observer : m_pluginLoadObservers)
+ observer->clearPluginContainer();
+#endif
if (m_webPlugin) {
RELEASE_ASSERT(!m_webPlugin->container() || m_webPlugin->container() == this);
m_webPlugin->destroy();
+ m_webPlugin = nullptr;
}
- m_webPlugin = nullptr;
if (m_webLayer) {
GraphicsLayer::unregisterContentsLayer(m_webLayer);
m_webLayer = nullptr;
}
+#if ENABLE(OILPAN)
+ if (!m_shouldDisposePlugin)
+ m_pluginLoadObservers.clear();
+#else
m_pluginLoadObservers.clear();
+#endif
m_element = nullptr;
}
@@ -757,7 +779,10 @@ void WebPluginContainerImpl::shouldDisposePlugin()
DEFINE_TRACE(WebPluginContainerImpl)
{
+#if ENABLE(OILPAN)
visitor->trace(m_element);
+ visitor->trace(m_pluginLoadObservers);
+#endif
LocalFrameLifecycleObserver::trace(visitor);
PluginView::trace(visitor);
}

Powered by Google App Engine
This is Rietveld 408576698