From 9354a6c2c69ea4ec178d32ee1acafcaa757d6af9 Mon Sep 17 00:00:00 2001 From: "kaznacheev@chromium.org" Date: Thu, 18 Apr 2013 12:50:29 +0000 Subject: Minor clean up in WorkerDevToolsManager BUG=None Review URL: https://chromiumcodereview.appspot.com/14051004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194902 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/devtools/worker_devtools_manager.cc | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'content/browser/devtools/worker_devtools_manager.cc') diff --git a/content/browser/devtools/worker_devtools_manager.cc b/content/browser/devtools/worker_devtools_manager.cc index db5cc74..d69be2b 100644 --- a/content/browser/devtools/worker_devtools_manager.cc +++ b/content/browser/devtools/worker_devtools_manager.cc @@ -61,11 +61,12 @@ class WorkerDevToolsManager::WorkerDevToolsAgentHost explicit WorkerDevToolsAgentHost(WorkerId worker_id) : has_worker_id_(false) { SetWorkerId(worker_id, false); - AddRef(); // Balanced in ResetWorkerId. } void SetWorkerId(WorkerId worker_id, bool reattach) { worker_id_ = worker_id; + if (!has_worker_id_) + AddRef(); // Balanced in ResetWorkerId. has_worker_id_ = true; g_agent_map.Get()[worker_id_] = this; @@ -84,7 +85,7 @@ class WorkerDevToolsManager::WorkerDevToolsAgentHost void ResetWorkerId() { g_agent_map.Get().erase(worker_id_); has_worker_id_ = false; - Release(); + Release(); // Balanced in SetWorkerId. } void SaveAgentRuntimeState(const std::string& state) { @@ -97,10 +98,7 @@ class WorkerDevToolsManager::WorkerDevToolsAgentHost } private: - virtual ~WorkerDevToolsAgentHost() { - g_agent_map.Get().erase(worker_id_); - g_orphan_map.Get().erase(worker_id_); - } + virtual ~WorkerDevToolsAgentHost(); static void ConnectToWorker( int worker_process_id, @@ -180,16 +178,16 @@ class WorkerDevToolsManager::DetachedClientHosts { agent->ResetWorkerId(); } - private: - DetachedClientHosts() {} - ~DetachedClientHosts() {} - static void RemovePendingWorkerData(WorkerId id) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&RemoveInspectedWorkerDataOnIOThread, id)); } + private: + DetachedClientHosts() {} + ~DetachedClientHosts() {} + static void RemoveInspectedWorkerDataOnIOThread(WorkerId id) { WorkerDevToolsManager::GetInstance()->RemoveInspectedWorkerData(id); } @@ -441,4 +439,10 @@ void WorkerDevToolsManager::SendResumeToWorker(const WorkerId& id) { process->Send(new DevToolsAgentMsg_ResumeWorkerContext(id.second)); } +WorkerDevToolsManager::WorkerDevToolsAgentHost::~WorkerDevToolsAgentHost() { + DetachedClientHosts::RemovePendingWorkerData(worker_id_); + g_agent_map.Get().erase(worker_id_); + g_orphan_map.Get().erase(worker_id_); +} + } // namespace content -- cgit v1.1