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

Unified Diff: Source/core/inspector/InspectorFrontendHost.cpp

Issue 665763002: Oilpan: move context menu providers to the heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated GC_PLUGIN_IGNORE() Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/InspectorFrontendHost.h ('k') | Source/core/page/ContextMenuController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorFrontendHost.cpp
diff --git a/Source/core/inspector/InspectorFrontendHost.cpp b/Source/core/inspector/InspectorFrontendHost.cpp
index 2e0298dbc86f81a5b36403d8c50f5d6533e65bf7..00e1a125fb3532ebf8bf94bd61e010d95363ad49 100644
--- a/Source/core/inspector/InspectorFrontendHost.cpp
+++ b/Source/core/inspector/InspectorFrontendHost.cpp
@@ -59,28 +59,39 @@ namespace blink {
class FrontendMenuProvider final : public ContextMenuProvider {
public:
- static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* frontendHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items)
+ static PassRefPtrWillBeRawPtr<FrontendMenuProvider> create(InspectorFrontendHost* frontendHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items)
{
- return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject, items));
+ return adoptRefWillBeNoop(new FrontendMenuProvider(frontendHost, frontendApiObject, items));
}
- void disconnect()
+ virtual ~FrontendMenuProvider()
{
- m_frontendApiObject = ScriptValue();
- m_frontendHost = 0;
+ // Verify that this menu provider has been detached.
+ ASSERT(!m_frontendHost);
}
-private:
- FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items)
- : m_frontendHost(frontendHost)
- , m_frontendApiObject(frontendApiObject)
- , m_items(items)
+ virtual void trace(Visitor* visitor) override
{
+ visitor->trace(m_frontendHost);
+ ContextMenuProvider::trace(visitor);
}
- virtual ~FrontendMenuProvider()
+ void disconnect()
{
- contextMenuCleared();
+ m_frontendApiObject = ScriptValue();
+ m_frontendHost = nullptr;
+ }
+
+ virtual void contextMenuCleared() override
+ {
+ if (m_frontendHost) {
+ ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared");
+ function.call();
+
+ m_frontendHost->clearMenuProvider();
+ m_frontendHost = nullptr;
+ }
+ m_items.clear();
}
virtual void populateContextMenu(ContextMenu* menu) override
@@ -91,37 +102,38 @@ private:
virtual void contextMenuItemSelected(const ContextMenuItem* item) override
{
- if (m_frontendHost) {
- UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
- int itemNumber = item->action() - ContextMenuItemBaseCustomTag;
+ if (!m_frontendHost)
+ return;
- ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSelected");
- function.appendArgument(itemNumber);
- function.call();
- }
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
+ int itemNumber = item->action() - ContextMenuItemBaseCustomTag;
+
+ ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSelected");
+ function.appendArgument(itemNumber);
+ function.call();
}
- virtual void contextMenuCleared() override
+private:
+ FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items)
+ : m_frontendHost(frontendHost)
+ , m_frontendApiObject(frontendApiObject)
+ , m_items(items)
{
- if (m_frontendHost) {
- ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared");
- function.call();
-
- m_frontendHost->m_menuProvider = 0;
- }
- m_items.clear();
- m_frontendHost = 0;
}
- InspectorFrontendHost* m_frontendHost;
+ RawPtrWillBeMember<InspectorFrontendHost> m_frontendHost;
ScriptValue m_frontendApiObject;
+
+ // FIXME: Oilpan: remove when http://crbug.com/424962 Blink GC plugin
+ // changes have been deployed. ContextMenuItem triggers looping behavior.
+ GC_PLUGIN_IGNORE("crbug.com/424962")
Vector<ContextMenuItem> m_items;
};
InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client, Page* frontendPage)
: m_client(client)
, m_frontendPage(frontendPage)
- , m_menuProvider(0)
+ , m_menuProvider(nullptr)
{
}
@@ -133,13 +145,16 @@ InspectorFrontendHost::~InspectorFrontendHost()
void InspectorFrontendHost::trace(Visitor* visitor)
{
visitor->trace(m_frontendPage);
+ visitor->trace(m_menuProvider);
}
void InspectorFrontendHost::disconnectClient()
{
m_client = 0;
- if (m_menuProvider)
+ if (m_menuProvider) {
m_menuProvider->disconnect();
+ m_menuProvider = nullptr;
+ }
m_frontendPage = nullptr;
}
@@ -216,7 +231,7 @@ void InspectorFrontendHost::showContextMenu(Page* page, float x, float y, const
ScriptValue frontendApiObject = frontendScriptState->getFromGlobalObject("InspectorFrontendAPI");
ASSERT(frontendApiObject.isObject());
- RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, frontendApiObject, items);
+ RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, frontendApiObject, items);
m_menuProvider = menuProvider.get();
float zoom = page->deprecatedLocalMainFrame()->pageZoomFactor();
page->inspectorController().showContextMenu(x * zoom, y * zoom, menuProvider);
@@ -239,7 +254,7 @@ void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe
targetPage = window->document()->page();
}
- RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, frontendApiObject, items);
+ RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, frontendApiObject, items);
targetPage->contextMenuController().showContextMenu(event, menuProvider);
m_menuProvider = menuProvider.get();
}
« no previous file with comments | « Source/core/inspector/InspectorFrontendHost.h ('k') | Source/core/page/ContextMenuController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698