Commit bbc51c91 authored by yurys@chromium.org's avatar yurys@chromium.org

DevTools: remove obsolete methods from DevToolsClientHost

BUG=104625
TEST=Existing tests

Review URL: http://codereview.chromium.org/8636011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111139 0039d316-1c4b-4281-b951-d872f2087c98
parent 1d067221
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
...@@ -44,6 +45,13 @@ ...@@ -44,6 +45,13 @@
#include "content/public/common/bindings_policy.h" #include "content/public/common/bindings_policy.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
typedef std::vector<DevToolsWindow*> DevToolsWindowList;
namespace {
base::LazyInstance<DevToolsWindowList,
base::LeakyLazyInstanceTraits<DevToolsWindowList> >
g_instances = LAZY_INSTANCE_INITIALIZER;
} // namespace
const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp";
// static // static
...@@ -60,9 +68,6 @@ TabContentsWrapper* DevToolsWindow::GetDevToolsContents( ...@@ -60,9 +68,6 @@ TabContentsWrapper* DevToolsWindow::GetDevToolsContents(
return NULL; return NULL;
DevToolsManager* manager = DevToolsManager::GetInstance(); DevToolsManager* manager = DevToolsManager::GetInstance();
if (!manager)
return NULL; // Happens only in tests.
DevToolsClientHost* client_host = manager-> DevToolsClientHost* client_host = manager->
GetDevToolsClientHostFor(inspected_tab->render_view_host()); GetDevToolsClientHostFor(inspected_tab->render_view_host());
DevToolsWindow* window = AsDevToolsWindow(client_host); DevToolsWindow* window = AsDevToolsWindow(client_host);
...@@ -72,12 +77,16 @@ TabContentsWrapper* DevToolsWindow::GetDevToolsContents( ...@@ -72,12 +77,16 @@ TabContentsWrapper* DevToolsWindow::GetDevToolsContents(
} }
// static // static
DevToolsWindow* DevToolsWindow::FindDevToolsWindow( bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) {
RenderViewHost* window_rvh) { if (g_instances == NULL)
DevToolsClientHost* client_host = return NULL;
DevToolsClientHost::FindOwnerClientHost(window_rvh); DevToolsWindowList& instances = g_instances.Get();
return client_host != NULL ? DevToolsWindow::AsDevToolsWindow(client_host) for (DevToolsWindowList::iterator it = instances.begin();
: NULL; it != instances.end(); ++it) {
if ((*it)->tab_contents_->render_view_host() == window_rvh)
return true;
}
return false;
} }
// static // static
...@@ -163,6 +172,7 @@ DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents, ...@@ -163,6 +172,7 @@ DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents,
docked_(docked), docked_(docked),
is_loaded_(false), is_loaded_(false),
action_on_load_(DEVTOOLS_TOGGLE_ACTION_NONE) { action_on_load_(DEVTOOLS_TOGGLE_ACTION_NONE) {
g_instances.Get().push_back(this);
// Wipe out page icon so that the default application icon is used. // Wipe out page icon so that the default application icon is used.
NavigationEntry* entry = tab_contents_->controller().GetActiveEntry(); NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
entry->favicon().set_bitmap(SkBitmap()); entry->favicon().set_bitmap(SkBitmap());
...@@ -191,6 +201,12 @@ DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents, ...@@ -191,6 +201,12 @@ DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents,
} }
DevToolsWindow::~DevToolsWindow() { DevToolsWindow::~DevToolsWindow() {
DevToolsWindowList& instances = g_instances.Get();
DevToolsWindowList::iterator it = std::find(instances.begin(),
instances.end(),
this);
DCHECK(it != instances.end());
instances.erase(it);
} }
void DevToolsWindow::SendMessageToClient(const IPC::Message& message) { void DevToolsWindow::SendMessageToClient(const IPC::Message& message) {
...@@ -231,10 +247,6 @@ void DevToolsWindow::TabReplaced(TabContents* new_tab) { ...@@ -231,10 +247,6 @@ void DevToolsWindow::TabReplaced(TabContents* new_tab) {
inspected_tab_ = new_tab_wrapper; inspected_tab_ = new_tab_wrapper;
} }
RenderViewHost* DevToolsWindow::GetClientRenderViewHost() {
return tab_contents_->render_view_host();
}
void DevToolsWindow::Show(DevToolsToggleAction action) { void DevToolsWindow::Show(DevToolsToggleAction action) {
if (docked_) { if (docked_) {
Browser* inspected_browser; Browser* inspected_browser;
...@@ -646,10 +658,15 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( ...@@ -646,10 +658,15 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow(
// static // static
DevToolsWindow* DevToolsWindow::AsDevToolsWindow( DevToolsWindow* DevToolsWindow::AsDevToolsWindow(
DevToolsClientHost* client_host) { DevToolsClientHost* client_host) {
if (!client_host) if (!client_host || g_instances == NULL)
return NULL; return NULL;
if (client_host->GetClientRenderViewHost() != NULL) DevToolsWindowList& instances = g_instances.Get();
return static_cast<DevToolsWindow*>(client_host); for (DevToolsWindowList::iterator it = instances.begin();
it != instances.end(); ++it) {
DevToolsClientHost* client = *it;
if (client == client_host)
return *it;
}
return NULL; return NULL;
} }
......
...@@ -43,7 +43,7 @@ class DevToolsWindow ...@@ -43,7 +43,7 @@ class DevToolsWindow
static const char kDevToolsApp[]; static const char kDevToolsApp[];
static void RegisterUserPrefs(PrefService* prefs); static void RegisterUserPrefs(PrefService* prefs);
static TabContentsWrapper* GetDevToolsContents(TabContents* inspected_tab); static TabContentsWrapper* GetDevToolsContents(TabContents* inspected_tab);
static DevToolsWindow* FindDevToolsWindow(RenderViewHost* window_rvh); static bool IsDevToolsWindow(RenderViewHost* window_rvh);
static DevToolsWindow* OpenDevToolsWindowForWorker( static DevToolsWindow* OpenDevToolsWindowForWorker(
Profile* profile, Profile* profile,
...@@ -60,7 +60,6 @@ class DevToolsWindow ...@@ -60,7 +60,6 @@ class DevToolsWindow
virtual void SendMessageToClient(const IPC::Message& message) OVERRIDE; virtual void SendMessageToClient(const IPC::Message& message) OVERRIDE;
virtual void InspectedTabClosing() OVERRIDE; virtual void InspectedTabClosing() OVERRIDE;
virtual void TabReplaced(TabContents* new_tab) OVERRIDE; virtual void TabReplaced(TabContents* new_tab) OVERRIDE;
virtual RenderViewHost* GetClientRenderViewHost() OVERRIDE;
RenderViewHost* GetRenderViewHost(); RenderViewHost* GetRenderViewHost();
void Show(DevToolsToggleAction action); void Show(DevToolsToggleAction action);
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#include <cmath> #include <cmath>
#include "base/sys_string_conversions.h" #include "base/sys_string_conversions.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/spellchecker/spellchecker_platform_engine.h" #include "chrome/browser/spellchecker/spellchecker_platform_engine.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#import "chrome/browser/ui/cocoa/history_overlay_controller.h" #import "chrome/browser/ui/cocoa/history_overlay_controller.h"
#import "chrome/browser/ui/cocoa/view_id_util.h" #import "chrome/browser/ui/cocoa/view_id_util.h"
#include "chrome/common/spellcheck_messages.h" #include "chrome/common/spellcheck_messages.h"
#include "content/browser/debugger/devtools_client_host.h"
#include "content/browser/mac/closure_blocks_leopard_compat.h" #include "content/browser/mac/closure_blocks_leopard_compat.h"
#include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_view_host_observer.h" #include "content/browser/renderer_host/render_view_host_observer.h"
...@@ -165,8 +165,8 @@ class SpellCheckRenderViewObserver : public RenderViewHostObserver { ...@@ -165,8 +165,8 @@ class SpellCheckRenderViewObserver : public RenderViewHostObserver {
if (!render_widget_host_ || !render_widget_host_->IsRenderView()) if (!render_widget_host_ || !render_widget_host_->IsRenderView())
return NO; return NO;
bool isDevtoolsRwhv = DevToolsClientHost::FindOwnerClientHost( bool isDevtoolsRwhv = DevToolsWindow::IsDevToolsWindow(
static_cast<RenderViewHost*>(render_widget_host_)) != NULL; static_cast<RenderViewHost*>(render_widget_host_));
if (isDevtoolsRwhv) if (isDevtoolsRwhv)
return NO; return NO;
......
...@@ -2,45 +2,14 @@ ...@@ -2,45 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <algorithm>
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "content/browser/debugger/devtools_client_host.h" #include "content/browser/debugger/devtools_client_host.h"
#include "content/browser/debugger/devtools_manager.h"
typedef std::vector<DevToolsClientHost*> DevToolsClientHostList; #include "content/browser/debugger/devtools_manager.h"
namespace {
base::LazyInstance<DevToolsClientHostList,
base::LeakyLazyInstanceTraits<DevToolsClientHostList> >
g_instances = LAZY_INSTANCE_INITIALIZER;
} // namespace
// static
DevToolsClientHost* DevToolsClientHost::FindOwnerClientHost(
RenderViewHost* client_rvh) {
for (DevToolsClientHostList::iterator it = g_instances.Get().begin();
it != g_instances.Get().end(); ++it) {
if ((*it)->GetClientRenderViewHost() == client_rvh)
return *it;
}
return NULL;
}
DevToolsClientHost::~DevToolsClientHost() { DevToolsClientHost::~DevToolsClientHost() {
DevToolsClientHostList::iterator it = std::find(g_instances.Get().begin(),
g_instances.Get().end(),
this);
DCHECK(it != g_instances.Get().end());
g_instances.Get().erase(it);
}
RenderViewHost* DevToolsClientHost::GetClientRenderViewHost() {
return NULL;
} }
DevToolsClientHost::DevToolsClientHost() : close_listener_(NULL) { DevToolsClientHost::DevToolsClientHost() : close_listener_(NULL) {
g_instances.Get().push_back(this);
} }
void DevToolsClientHost::ForwardToDevToolsAgent(const IPC::Message& message) { void DevToolsClientHost::ForwardToDevToolsAgent(const IPC::Message& message) {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#pragma once #pragma once
#include <string> #include <string>
#include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
...@@ -16,7 +15,6 @@ namespace IPC { ...@@ -16,7 +15,6 @@ namespace IPC {
class Message; class Message;
} }
class RenderViewHost;
class TabContents; class TabContents;
// Describes interface for managing devtools clients from browser process. There // Describes interface for managing devtools clients from browser process. There
...@@ -33,8 +31,6 @@ class CONTENT_EXPORT DevToolsClientHost { ...@@ -33,8 +31,6 @@ class CONTENT_EXPORT DevToolsClientHost {
DISALLOW_COPY_AND_ASSIGN(CloseListener); DISALLOW_COPY_AND_ASSIGN(CloseListener);
}; };
static DevToolsClientHost* FindOwnerClientHost(RenderViewHost* client_rvh);
virtual ~DevToolsClientHost(); virtual ~DevToolsClientHost();
// This method is called when tab inspected by this devtools client is // This method is called when tab inspected by this devtools client is
...@@ -56,10 +52,6 @@ class CONTENT_EXPORT DevToolsClientHost { ...@@ -56,10 +52,6 @@ class CONTENT_EXPORT DevToolsClientHost {
// TabStripModel::ReplaceTabContentsAt. // TabStripModel::ReplaceTabContentsAt.
virtual void TabReplaced(TabContents* new_tab) = 0; virtual void TabReplaced(TabContents* new_tab) = 0;
// Returns client (front-end) RenderViewHost implementation of this
// client host if applicable. NULL otherwise.
virtual RenderViewHost* GetClientRenderViewHost();
protected: protected:
DevToolsClientHost(); DevToolsClientHost();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment