| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_renderer_state.h" | 5 #include "chrome/browser/extensions/extension_renderer_state.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 void ExtensionRendererState::ClearTabAndWindowId( | 199 void ExtensionRendererState::ClearTabAndWindowId( |
| 200 int render_process_host_id, int routing_id) { | 200 int render_process_host_id, int routing_id) { |
| 201 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 201 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 202 RenderId render_id(render_process_host_id, routing_id); | 202 RenderId render_id(render_process_host_id, routing_id); |
| 203 map_.erase(render_id); | 203 map_.erase(render_id); |
| 204 } | 204 } |
| 205 | 205 |
| 206 bool ExtensionRendererState::GetTabAndWindowId( | 206 bool ExtensionRendererState::GetTabAndWindowId( |
| 207 const content::ResourceRequestInfo* info, int* tab_id, int* window_id) { | 207 const content::ResourceRequestInfo* info, int* tab_id, int* window_id) { |
| 208 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 208 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 209 int render_process_id; | 209 int render_process_id = info->GetChildID(); |
| 210 if (info->GetProcessType() == content::PROCESS_TYPE_PLUGIN) { | |
| 211 render_process_id = info->GetOriginPID(); | |
| 212 } else { | |
| 213 render_process_id = info->GetChildID(); | |
| 214 } | |
| 215 int render_view_id = info->GetRouteID(); | 210 int render_view_id = info->GetRouteID(); |
| 216 RenderId render_id(render_process_id, render_view_id); | 211 RenderId render_id(render_process_id, render_view_id); |
| 217 TabAndWindowIdMap::iterator iter = map_.find(render_id); | 212 TabAndWindowIdMap::iterator iter = map_.find(render_id); |
| 218 bool found = false; | 213 bool found = false; |
| 219 if (iter != map_.end()) { | 214 if (iter != map_.end()) { |
| 220 *tab_id = iter->second.first; | 215 *tab_id = iter->second.first; |
| 221 *window_id = iter->second.second; | 216 *window_id = iter->second.second; |
| 222 found = true; | 217 found = true; |
| 223 } | 218 } |
| 224 UMA_HISTOGRAM_BOOLEAN("Extensions.ExtensionRendererStateCacheHit", found); | 219 UMA_HISTOGRAM_BOOLEAN("Extensions.ExtensionRendererStateCacheHit", found); |
| 225 return found; | 220 return found; |
| 226 } | 221 } |
| OLD | NEW |