Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "extensions/browser/extension_api_frame_id_map.h" | 5 #include "extensions/browser/extension_api_frame_id_map.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 found = true; | 299 found = true; |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 // TODO(devlin): Depending on how the data looks, this may be removable after | 303 // TODO(devlin): Depending on how the data looks, this may be removable after |
| 304 // a few cycles. Check back in M52 to see if it's still needed. | 304 // a few cycles. Check back in M52 to see if it's still needed. |
| 305 UMA_HISTOGRAM_BOOLEAN("Extensions.ExtensionFrameMapCacheHit", found); | 305 UMA_HISTOGRAM_BOOLEAN("Extensions.ExtensionFrameMapCacheHit", found); |
| 306 return found; | 306 return found; |
| 307 } | 307 } |
| 308 | 308 |
| 309 ExtensionApiFrameIdMap::FrameData ExtensionApiFrameIdMap::GetFrameData( | |
| 310 content::RenderFrameHost* rfh) { | |
| 311 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 312 | |
| 313 const RenderFrameIdKey key(rfh->GetProcess()->GetID(), rfh->GetRoutingID()); | |
| 314 return LookupFrameDataOnUI(key, true /* for lookup */); | |
|
Devlin
2016/05/23 20:28:48
In retrospect, this was probably a poorly named bo
robwu
2016/05/23 20:54:15
Done. for_lookup_after_cache_miss was a bit too lo
Devlin
2016/05/23 20:56:12
sgtm
| |
| 315 } | |
| 316 | |
| 309 void ExtensionApiFrameIdMap::CacheFrameData(content::RenderFrameHost* rfh) { | 317 void ExtensionApiFrameIdMap::CacheFrameData(content::RenderFrameHost* rfh) { |
| 310 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 318 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 311 | 319 |
| 312 const RenderFrameIdKey key(rfh->GetProcess()->GetID(), rfh->GetRoutingID()); | 320 const RenderFrameIdKey key(rfh->GetProcess()->GetID(), rfh->GetRoutingID()); |
| 313 CacheFrameData(key); | 321 CacheFrameData(key); |
| 314 DCHECK(frame_data_map_.find(key) != frame_data_map_.end()); | 322 DCHECK(frame_data_map_.find(key) != frame_data_map_.end()); |
| 315 } | 323 } |
| 316 | 324 |
| 317 void ExtensionApiFrameIdMap::CacheFrameData(const RenderFrameIdKey& key) { | 325 void ExtensionApiFrameIdMap::CacheFrameData(const RenderFrameIdKey& key) { |
| 318 LookupFrameDataOnUI(key, false /* not for lookup */); | 326 LookupFrameDataOnUI(key, false /* not for lookup */); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 345 } | 353 } |
| 346 | 354 |
| 347 void ExtensionApiFrameIdMap::RemoveFrameData(const RenderFrameIdKey& key) { | 355 void ExtensionApiFrameIdMap::RemoveFrameData(const RenderFrameIdKey& key) { |
| 348 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 356 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 349 | 357 |
| 350 base::AutoLock lock(frame_data_map_lock_); | 358 base::AutoLock lock(frame_data_map_lock_); |
| 351 frame_data_map_.erase(key); | 359 frame_data_map_.erase(key); |
| 352 } | 360 } |
| 353 | 361 |
| 354 } // namespace extensions | 362 } // namespace extensions |
| OLD | NEW |