summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 06:38:26 +0000
committeryurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 06:38:26 +0000
commitdc8614a01d9e46eb5d7848141d5d189295c5f31c (patch)
treec8f53c74ac761de43e8db0fe10b8034a6ac3fcf1
parent9db0f6980e94e86eaa170f0b9035eb377f9742c0 (diff)
downloadchromium_src-dc8614a01d9e46eb5d7848141d5d189295c5f31c.zip
chromium_src-dc8614a01d9e46eb5d7848141d5d189295c5f31c.tar.gz
chromium_src-dc8614a01d9e46eb5d7848141d5d189295c5f31c.tar.bz2
Make DevToolsManager a singleton, remove it from ContentBrowserClient.
DevToolsManager should be created and destroyed inside content implementation, not by the embedder. BUG=104625 TEST=Exising tests Review URL: http://codereview.chromium.org/8609010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111106 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_process.h2
-rw-r--r--chrome/browser/browser_process_impl.cc15
-rw-r--r--chrome/browser/browser_process_impl.h5
-rw-r--r--chrome/browser/chrome_content_browser_client.cc4
-rw-r--r--chrome/browser/chrome_content_browser_client.h1
-rw-r--r--chrome/browser/ui/browser.cc2
-rw-r--r--chrome/test/base/testing_browser_process.cc12
-rw-r--r--chrome/test/base/testing_browser_process.h3
-rw-r--r--content/browser/debugger/devtools_manager.cc3
-rw-r--r--content/browser/debugger/devtools_manager.h3
-rw-r--r--content/browser/debugger/devtools_manager_unittest.cc8
-rw-r--r--content/browser/mock_content_browser_client.cc4
-rw-r--r--content/browser/mock_content_browser_client.h1
-rw-r--r--content/public/browser/content_browser_client.h2
-rw-r--r--content/shell/shell_content_browser_client.cc4
-rw-r--r--content/shell/shell_content_browser_client.h1
16 files changed, 7 insertions, 63 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index f4c695a..4db6a0a 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -23,7 +23,6 @@ class BackgroundModeManager;
class ChromeNetLog;
class CRLSetFetcher;
class ComponentUpdateService;
-class DevToolsManager;
class DownloadRequestLimiter;
class DownloadStatusUpdater;
class ExtensionEventRouterForwarder;
@@ -101,7 +100,6 @@ class BrowserProcess {
virtual MetricsService* metrics_service() = 0;
virtual ProfileManager* profile_manager() = 0;
virtual PrefService* local_state() = 0;
- virtual DevToolsManager* devtools_manager() = 0;
virtual SidebarManager* sidebar_manager() = 0;
virtual ui::Clipboard* clipboard() = 0;
virtual net::URLRequestContextGetter* system_request_context() = 0;
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index fad4533..843cce0 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -71,7 +71,6 @@
#include "chrome/installer/util/google_update_constants.h"
#include "content/browser/browser_process_sub_thread.h"
#include "content/browser/child_process_security_policy.h"
-#include "content/browser/debugger/devtools_manager.h"
#include "content/browser/download/download_file_manager.h"
#include "content/browser/download/download_status_updater.h"
#include "content/browser/download/mhtml_generation_manager.h"
@@ -138,7 +137,6 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
created_profile_manager_(false),
created_local_state_(false),
created_icon_manager_(false),
- created_devtools_manager_(false),
created_sidebar_manager_(false),
created_browser_policy_connector_(false),
created_notification_ui_manager_(false),
@@ -466,13 +464,6 @@ PrefService* BrowserProcessImpl::local_state() {
return local_state_.get();
}
-DevToolsManager* BrowserProcessImpl::devtools_manager() {
- DCHECK(CalledOnValidThread());
- if (!created_devtools_manager_)
- CreateDevToolsManager();
- return devtools_manager_.get();
-}
-
SidebarManager* BrowserProcessImpl::sidebar_manager() {
DCHECK(CalledOnValidThread());
if (!created_sidebar_manager_)
@@ -957,12 +948,6 @@ void BrowserProcessImpl::CreateIconManager() {
icon_manager_.reset(new IconManager);
}
-void BrowserProcessImpl::CreateDevToolsManager() {
- DCHECK(devtools_manager_.get() == NULL);
- created_devtools_manager_ = true;
- devtools_manager_.reset(new DevToolsManager());
-}
-
void BrowserProcessImpl::CreateSidebarManager() {
DCHECK(sidebar_manager_.get() == NULL);
created_sidebar_manager_ = true;
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index e3b9d994..997046e 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -61,7 +61,6 @@ class BrowserProcessImpl : public BrowserProcess,
#endif
virtual ProfileManager* profile_manager() OVERRIDE;
virtual PrefService* local_state() OVERRIDE;
- virtual DevToolsManager* devtools_manager() OVERRIDE;
virtual SidebarManager* sidebar_manager() OVERRIDE;
virtual ui::Clipboard* clipboard() OVERRIDE;
virtual net::URLRequestContextGetter* system_request_context() OVERRIDE;
@@ -141,7 +140,6 @@ class BrowserProcessImpl : public BrowserProcess,
void CreateLocalState();
void CreateViewedPageTracker();
void CreateIconManager();
- void CreateDevToolsManager();
void CreateSidebarManager();
void CreateGoogleURLTracker();
void CreateIntranetRedirectDetector();
@@ -204,9 +202,6 @@ class BrowserProcessImpl : public BrowserProcess,
scoped_refptr<DevToolsProtocolHandler> devtools_legacy_handler_;
- bool created_devtools_manager_;
- scoped_ptr<DevToolsManager> devtools_manager_;
-
bool created_sidebar_manager_;
scoped_refptr<SidebarManager> sidebar_manager_;
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 62fe5b0..0e37f80 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -1009,10 +1009,6 @@ MHTMLGenerationManager*
return g_browser_process->mhtml_generation_manager();
}
-DevToolsManager* ChromeContentBrowserClient::GetDevToolsManager() {
- return g_browser_process->devtools_manager();
-}
-
net::NetLog* ChromeContentBrowserClient::GetNetLog() {
return g_browser_process->net_log();
}
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index e174d4d..3e495a0 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -122,7 +122,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
virtual ResourceDispatcherHost* GetResourceDispatcherHost() OVERRIDE;
virtual ui::Clipboard* GetClipboard() OVERRIDE;
virtual MHTMLGenerationManager* GetMHTMLGenerationManager() OVERRIDE;
- virtual DevToolsManager* GetDevToolsManager() OVERRIDE;
virtual net::NetLog* GetNetLog() OVERRIDE;
virtual speech_input::SpeechInputManager* GetSpeechInputManager() OVERRIDE;
virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 03659e3..1948bf3 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -4142,7 +4142,7 @@ void Browser::Observe(int type,
} else if (pref_name == prefs::kDevToolsDisabled) {
UpdateCommandsForDevTools();
if (profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled))
- g_browser_process->devtools_manager()->CloseAllClientHosts();
+ DevToolsManager::GetInstance()->CloseAllClientHosts();
} else if (pref_name == prefs::kEditBookmarksEnabled) {
UpdateCommandsForBookmarkEditing();
} else if (pref_name == prefs::kShowBookmarkBar) {
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index 9ac09de..939848b 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "content/browser/debugger/devtools_manager.h"
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/clipboard/clipboard.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,8 +21,7 @@ TestingBrowserProcess::TestingBrowserProcess()
: module_ref_count_(0),
app_locale_("en"),
local_state_(NULL),
- io_thread_(NULL),
- devtools_manager_(NULL) {
+ io_thread_(NULL) {
}
TestingBrowserProcess::~TestingBrowserProcess() {
@@ -96,10 +94,6 @@ ThumbnailGenerator* TestingBrowserProcess::GetThumbnailGenerator() {
return NULL;
}
-DevToolsManager* TestingBrowserProcess::devtools_manager() {
- return devtools_manager_.get();
-}
-
SidebarManager* TestingBrowserProcess::sidebar_manager() {
return NULL;
}
@@ -272,10 +266,6 @@ void TestingBrowserProcess::SetIOThread(IOThread* io_thread) {
io_thread_ = io_thread;
}
-void TestingBrowserProcess::SetDevToolsManager(DevToolsManager* manager) {
- devtools_manager_.reset(manager);
-}
-
void TestingBrowserProcess::SetBrowserPolicyConnector(
policy::BrowserPolicyConnector* connector) {
browser_policy_connector_.reset(connector);
diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h
index d308651..6846eea 100644
--- a/chrome/test/base/testing_browser_process.h
+++ b/chrome/test/base/testing_browser_process.h
@@ -63,7 +63,6 @@ class TestingBrowserProcess : public BrowserProcess {
virtual policy::BrowserPolicyConnector* browser_policy_connector() OVERRIDE;
virtual IconManager* icon_manager() OVERRIDE;
virtual ThumbnailGenerator* GetThumbnailGenerator() OVERRIDE;
- virtual DevToolsManager* devtools_manager() OVERRIDE;
virtual SidebarManager* sidebar_manager() OVERRIDE;
virtual TabCloseableStateWatcher* tab_closeable_state_watcher() OVERRIDE;
virtual BackgroundModeManager* background_mode_manager() OVERRIDE;
@@ -121,7 +120,6 @@ class TestingBrowserProcess : public BrowserProcess {
void SetGoogleURLTracker(GoogleURLTracker* google_url_tracker);
void SetProfileManager(ProfileManager* profile_manager);
void SetIOThread(IOThread* io_thread);
- void SetDevToolsManager(DevToolsManager* manager);
void SetBrowserPolicyConnector(policy::BrowserPolicyConnector* connector);
private:
@@ -141,7 +139,6 @@ class TestingBrowserProcess : public BrowserProcess {
print_preview_tab_controller_;
scoped_ptr<prerender::PrerenderTracker> prerender_tracker_;
IOThread* io_thread_;
- scoped_ptr<DevToolsManager> devtools_manager_;
DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess);
};
diff --git a/content/browser/debugger/devtools_manager.cc b/content/browser/debugger/devtools_manager.cc
index 11b661f..3929ce8 100644
--- a/content/browser/debugger/devtools_manager.cc
+++ b/content/browser/debugger/devtools_manager.cc
@@ -16,14 +16,13 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/content_browser_client.h"
#include "googleurl/src/gurl.h"
using content::BrowserThread;
// static
DevToolsManager* DevToolsManager::GetInstance() {
- return content::GetContentClient()->browser()->GetDevToolsManager();
+ return Singleton<DevToolsManager>::get();
}
DevToolsManager::DevToolsManager()
diff --git a/content/browser/debugger/devtools_manager.h b/content/browser/debugger/devtools_manager.h
index 1801d0c..f589c85 100644
--- a/content/browser/debugger/devtools_manager.h
+++ b/content/browser/debugger/devtools_manager.h
@@ -10,6 +10,7 @@
#include <string>
#include "base/compiler_specific.h"
+#include "base/memory/singleton.h"
#include "content/browser/debugger/devtools_agent_host.h"
#include "content/browser/debugger/devtools_client_host.h"
#include "content/common/content_export.h"
@@ -88,6 +89,8 @@ class CONTENT_EXPORT DevToolsManager
int DetachClientHost(DevToolsAgentHost* from_agent);
private:
+ friend struct DefaultSingletonTraits<DevToolsManager>;
+
// DevToolsClientHost::CloseListener override.
// This method will remove all references from the manager to the
// DevToolsClientHost and unregister all listeners related to the
diff --git a/content/browser/debugger/devtools_manager_unittest.cc b/content/browser/debugger/devtools_manager_unittest.cc
index a2b3bf0..f7daf85 100644
--- a/content/browser/debugger/devtools_manager_unittest.cc
+++ b/content/browser/debugger/devtools_manager_unittest.cc
@@ -92,10 +92,6 @@ class DevToolsManagerTestBrowserClient
DevToolsManagerTestBrowserClient() {
}
- virtual DevToolsManager* GetDevToolsManager() OVERRIDE {
- return &dev_tools_manager_;
- }
-
virtual bool ShouldSwapProcessesForNavigation(
const GURL& current_url,
const GURL& new_url) OVERRIDE {
@@ -103,8 +99,6 @@ class DevToolsManagerTestBrowserClient
}
private:
- DevToolsManager dev_tools_manager_;
-
DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient);
};
@@ -182,7 +176,7 @@ TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) {
contents()->set_delegate(&delegate);
TestDevToolsClientHost client_host;
- content::GetContentClient()->browser()->GetDevToolsManager()->
+ DevToolsManager::GetInstance()->
RegisterDevToolsClientHostFor(inspected_rvh, &client_host);
// Start with a short timeout.
diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc
index 5b1c08b..b2e5421 100644
--- a/content/browser/mock_content_browser_client.cc
+++ b/content/browser/mock_content_browser_client.cc
@@ -250,10 +250,6 @@ MHTMLGenerationManager* MockContentBrowserClient::GetMHTMLGenerationManager() {
return NULL;
}
-DevToolsManager* MockContentBrowserClient::GetDevToolsManager() {
- return NULL;
-}
-
net::NetLog* MockContentBrowserClient::GetNetLog() {
return NULL;
}
diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h
index 2b61f71..fc6f5e77 100644
--- a/content/browser/mock_content_browser_client.h
+++ b/content/browser/mock_content_browser_client.h
@@ -129,7 +129,6 @@ class MockContentBrowserClient : public ContentBrowserClient {
virtual ResourceDispatcherHost* GetResourceDispatcherHost() OVERRIDE;
virtual ui::Clipboard* GetClipboard() OVERRIDE;
virtual MHTMLGenerationManager* GetMHTMLGenerationManager() OVERRIDE;
- virtual DevToolsManager* GetDevToolsManager() OVERRIDE;
virtual net::NetLog* GetNetLog() OVERRIDE;
virtual speech_input::SpeechInputManager* GetSpeechInputManager() OVERRIDE;
virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 7d5438e..18fd551 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -17,7 +17,6 @@
class AccessTokenStore;
class BrowserURLHandler;
class CommandLine;
-class DevToolsManager;
class FilePath;
class GURL;
class MHTMLGenerationManager;
@@ -307,7 +306,6 @@ class ContentBrowserClient {
virtual ResourceDispatcherHost* GetResourceDispatcherHost() = 0;
virtual ui::Clipboard* GetClipboard() = 0;
virtual MHTMLGenerationManager* GetMHTMLGenerationManager() = 0;
- virtual DevToolsManager* GetDevToolsManager() = 0;
virtual net::NetLog* GetNetLog() = 0;
virtual speech_input::SpeechInputManager* GetSpeechInputManager() = 0;
diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc
index 394af26..0958917 100644
--- a/content/shell/shell_content_browser_client.cc
+++ b/content/shell/shell_content_browser_client.cc
@@ -263,10 +263,6 @@ MHTMLGenerationManager* ShellContentBrowserClient::GetMHTMLGenerationManager() {
return NULL;
}
-DevToolsManager* ShellContentBrowserClient::GetDevToolsManager() {
- return NULL;
-}
-
net::NetLog* ShellContentBrowserClient::GetNetLog() {
return NULL;
}
diff --git a/content/shell/shell_content_browser_client.h b/content/shell/shell_content_browser_client.h
index 4d0ac37..65219e0 100644
--- a/content/shell/shell_content_browser_client.h
+++ b/content/shell/shell_content_browser_client.h
@@ -142,7 +142,6 @@ class ShellContentBrowserClient : public ContentBrowserClient
virtual ResourceDispatcherHost* GetResourceDispatcherHost() OVERRIDE;
virtual ui::Clipboard* GetClipboard() OVERRIDE;
virtual MHTMLGenerationManager* GetMHTMLGenerationManager() OVERRIDE;
- virtual DevToolsManager* GetDevToolsManager() OVERRIDE;
virtual net::NetLog* GetNetLog() OVERRIDE;
virtual speech_input::SpeechInputManager* GetSpeechInputManager() OVERRIDE;
virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE;