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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 if (navigation_handle->IsInMainFrame()) | 125 if (navigation_handle->IsInMainFrame()) |
| 126 return -1; | 126 return -1; |
| 127 | 127 |
| 128 if (navigation_handle->IsParentMainFrame()) | 128 if (navigation_handle->IsParentMainFrame()) |
| 129 return 0; | 129 return 0; |
| 130 | 130 |
| 131 return navigation_handle->GetParentFrameTreeNodeId(); | 131 return navigation_handle->GetParentFrameTreeNodeId(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // static | 134 // static |
| 135 void ExtensionApiFrameIdMap::GetTabAndWindowId(content::RenderFrameHost* rfh, | |
| 136 int* tab_id_out, | |
| 137 int* window_id_out) { | |
| 138 ExtensionApiFrameIdMapHelper* helper = | |
|
Devlin
2016/05/23 16:23:18
(if we keep this, dcheck ui thread)
Why do we do
robwu
2016/05/23 17:55:55
I didn't realize that the tab ID was immediately s
| |
| 139 ExtensionApiFrameIdMap::Get()->helper_.get(); | |
| 140 if (helper) | |
| 141 helper->GetTabAndWindowId(rfh, tab_id_out, window_id_out); | |
| 142 } | |
| 143 | |
| 144 // static | |
| 135 content::RenderFrameHost* ExtensionApiFrameIdMap::GetRenderFrameHostById( | 145 content::RenderFrameHost* ExtensionApiFrameIdMap::GetRenderFrameHostById( |
| 136 content::WebContents* web_contents, | 146 content::WebContents* web_contents, |
| 137 int frame_id) { | 147 int frame_id) { |
| 138 // Although it is technically possible to map |frame_id| to a RenderFrameHost | 148 // Although it is technically possible to map |frame_id| to a RenderFrameHost |
| 139 // without WebContents, we choose to not do that because in the extension API | 149 // without WebContents, we choose to not do that because in the extension API |
| 140 // frameIds are only guaranteed to be meaningful in combination with a tabId. | 150 // frameIds are only guaranteed to be meaningful in combination with a tabId. |
| 141 if (!web_contents) | 151 if (!web_contents) |
| 142 return nullptr; | 152 return nullptr; |
| 143 | 153 |
| 144 if (frame_id == kInvalidFrameId) | 154 if (frame_id == kInvalidFrameId) |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 } | 355 } |
| 346 | 356 |
| 347 void ExtensionApiFrameIdMap::RemoveFrameData(const RenderFrameIdKey& key) { | 357 void ExtensionApiFrameIdMap::RemoveFrameData(const RenderFrameIdKey& key) { |
| 348 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 358 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 349 | 359 |
| 350 base::AutoLock lock(frame_data_map_lock_); | 360 base::AutoLock lock(frame_data_map_lock_); |
| 351 frame_data_map_.erase(key); | 361 frame_data_map_.erase(key); |
| 352 } | 362 } |
| 353 | 363 |
| 354 } // namespace extensions | 364 } // namespace extensions |
| OLD | NEW |