Chromium Code Reviews| Index: Source/core/inspector/InspectorFrontendHost.cpp |
| diff --git a/Source/core/inspector/InspectorFrontendHost.cpp b/Source/core/inspector/InspectorFrontendHost.cpp |
| index 2e0298dbc86f81a5b36403d8c50f5d6533e65bf7..775abc935cb79a38aadb216f4dcc3b693a093c05 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,39 @@ 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: until http://crrev.com/666473003/ is used by the Blink |
| + // GC plugin, turn off checking for GC roots for this field. ContextMenuItem |
| + // triggers looping behavior. |
| + GC_PLUGIN_IGNORE("") |
|
sof
2014/10/19 19:36:55
Will update to refer to http://crbug.com/424962 be
|
| Vector<ContextMenuItem> m_items; |
| }; |
| InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client, Page* frontendPage) |
| : m_client(client) |
| , m_frontendPage(frontendPage) |
| - , m_menuProvider(0) |
| + , m_menuProvider(nullptr) |
| { |
| } |
| @@ -133,13 +146,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 +232,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 +255,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(); |
| } |