diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-25 16:30:43 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-25 16:30:43 +0000 |
commit | 1e99f81b31e3de9d7b195adfb355f814bb24fd5a (patch) | |
tree | 377209c9e3fbbd2f89f2c5467ccd0e2545e5743c /chrome/browser/debugger/devtools_manager.cc | |
parent | 9fdd6dabf4c64e2cf654c59bfe237a9d06452bba (diff) | |
download | chromium_src-1e99f81b31e3de9d7b195adfb355f814bb24fd5a.zip chromium_src-1e99f81b31e3de9d7b195adfb355f814bb24fd5a.tar.gz chromium_src-1e99f81b31e3de9d7b195adfb355f814bb24fd5a.tar.bz2 |
DevTools: Fix devtools crasher related to unsuccessful extensions reload with opened devtools window.
BUG=31081
Review URL: http://codereview.chromium.org/1328003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger/devtools_manager.cc')
-rw-r--r-- | chrome/browser/debugger/devtools_manager.cc | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc index d4d3971..bceec77 100644 --- a/chrome/browser/debugger/devtools_manager.cc +++ b/chrome/browser/debugger/devtools_manager.cc @@ -60,11 +60,10 @@ void DevToolsManager::RegisterDevToolsClientHostFor( DevToolsClientHost* client_host) { DCHECK(!GetDevToolsClientHostFor(inspected_rvh)); - inspected_rvh_to_client_host_[inspected_rvh] = client_host; - client_host_to_inspected_rvh_[client_host] = inspected_rvh; + RuntimeFeatures initial_features; + BindClientHost(inspected_rvh, client_host, initial_features); client_host->set_close_listener(this); - - SendAttachToAgent(inspected_rvh, std::set<std::string>()); + SendAttachToAgent(inspected_rvh); } void DevToolsManager::ForwardToDevToolsAgent( @@ -136,12 +135,12 @@ void DevToolsManager::ToggleDevToolsWindow(RenderViewHost* inspected_rvh, void DevToolsManager::RuntimeFeatureStateChanged(RenderViewHost* inspected_rvh, const std::string& feature, bool enabled) { - RuntimeFeaturesMap::iterator it = runtime_features_.find(inspected_rvh); - if (it == runtime_features_.end()) { + RuntimeFeaturesMap::iterator it = runtime_features_map_.find(inspected_rvh); + if (it == runtime_features_map_.end()) { std::pair<RenderViewHost*, std::set<std::string> > value( inspected_rvh, std::set<std::string>()); - it = runtime_features_.insert(value).first; + it = runtime_features_map_.insert(value).first; } if (enabled) it->second.insert(feature); @@ -178,10 +177,7 @@ void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) { Details<RenderViewHost>(inspected_rvh)); SendDetachToAgent(inspected_rvh); - - inspected_rvh_to_client_host_.erase(inspected_rvh); - runtime_features_.erase(inspected_rvh); - client_host_to_inspected_rvh_.erase(host); + UnbindClientHost(inspected_rvh, host); } RenderViewHost* DevToolsManager::GetInspectedRenderViewHost( @@ -198,10 +194,8 @@ void DevToolsManager::UnregisterDevToolsClientHostFor( DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh); if (!host) return; - inspected_rvh_to_client_host_.erase(inspected_rvh); - runtime_features_.erase(inspected_rvh); + UnbindClientHost(inspected_rvh, host); - client_host_to_inspected_rvh_.erase(host); if (inspected_rvh_for_reopen_ == inspected_rvh) inspected_rvh_for_reopen_ = NULL; @@ -260,10 +254,9 @@ int DevToolsManager::DetachClientHost(RenderViewHost* from_rvh) { int cookie = last_orphan_cookie_++; orphan_client_hosts_[cookie] = std::pair<DevToolsClientHost*, RuntimeFeatures>( - client_host, runtime_features_[from_rvh]); + client_host, runtime_features_map_[from_rvh]); - inspected_rvh_to_client_host_.erase(from_rvh); - runtime_features_.erase(from_rvh); + UnbindClientHost(from_rvh, client_host); return cookie; } @@ -275,21 +268,24 @@ void DevToolsManager::AttachClientHost(int client_host_cookie, return; DevToolsClientHost* client_host = (*it).second.first; - inspected_rvh_to_client_host_[to_rvh] = client_host; - client_host_to_inspected_rvh_[client_host] = to_rvh; - SendAttachToAgent(to_rvh, (*it).second.second); + BindClientHost(to_rvh, client_host, (*it).second.second); + SendAttachToAgent(to_rvh); orphan_client_hosts_.erase(client_host_cookie); } -void DevToolsManager::SendAttachToAgent( - RenderViewHost* inspected_rvh, - const std::set<std::string>& runtime_features) { +void DevToolsManager::SendAttachToAgent(RenderViewHost* inspected_rvh) { if (inspected_rvh) { ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies( inspected_rvh->process()->id()); - std::vector<std::string> features(runtime_features.begin(), - runtime_features.end()); + + std::vector<std::string> features; + RuntimeFeaturesMap::iterator it = + runtime_features_map_.find(inspected_rvh); + if (it != runtime_features_map_.end()) { + features = std::vector<std::string>(it->second.begin(), + it->second.end()); + } IPC::Message* m = new DevToolsAgentMsg_Attach(features); m->set_routing_id(inspected_rvh->routing_id()); inspected_rvh->Send(m); @@ -378,3 +374,28 @@ void DevToolsManager::CloseWindow(DevToolsClientHost* client_host) { UnregisterDevToolsClientHostFor(inspected_rvh); } + +void DevToolsManager::BindClientHost(RenderViewHost* inspected_rvh, + DevToolsClientHost* client_host, + const RuntimeFeatures& runtime_features) { + DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh) == + inspected_rvh_to_client_host_.end()); + DCHECK(client_host_to_inspected_rvh_.find(client_host) == + client_host_to_inspected_rvh_.end()); + + inspected_rvh_to_client_host_[inspected_rvh] = client_host; + client_host_to_inspected_rvh_[client_host] = inspected_rvh; + runtime_features_map_[inspected_rvh] = runtime_features; +} + +void DevToolsManager::UnbindClientHost(RenderViewHost* inspected_rvh, + DevToolsClientHost* client_host) { + DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh)->second == + client_host); + DCHECK(client_host_to_inspected_rvh_.find(client_host)->second == + inspected_rvh); + + inspected_rvh_to_client_host_.erase(inspected_rvh); + client_host_to_inspected_rvh_.erase(client_host); + runtime_features_map_.erase(inspected_rvh); +} |