Chromium Code Reviews| Index: chrome/browser/memory/tab_manager.cc |
| diff --git a/chrome/browser/memory/tab_manager.cc b/chrome/browser/memory/tab_manager.cc |
| index a99e6abdc048bd79f91e73bd4fe68c6b523fc5f1..d56e5fa82f3461c358fb52235b08a42cd28026d5 100644 |
| --- a/chrome/browser/memory/tab_manager.cc |
| +++ b/chrome/browser/memory/tab_manager.cc |
| @@ -88,12 +88,6 @@ const int kSuspendThresholdSeconds = kAdjustmentIntervalSeconds * 4; |
| // audible. |
| const int kAudioProtectionTimeSeconds = 60; |
| -// Returns a unique ID for a WebContents. Do not cast back to a pointer, as |
| -// the WebContents could be deleted if the user closed the tab. |
| -int64_t IdFromWebContents(WebContents* web_contents) { |
| - return reinterpret_cast<int64_t>(web_contents); |
| -} |
| - |
| int FindTabStripModelById(int64_t target_web_contents_id, |
| TabStripModel** model) { |
| DCHECK(model); |
| @@ -101,7 +95,7 @@ int FindTabStripModelById(int64_t target_web_contents_id, |
| TabStripModel* local_model = browser->tab_strip_model(); |
| for (int idx = 0; idx < local_model->count(); idx++) { |
| WebContents* web_contents = local_model->GetWebContentsAt(idx); |
| - int64_t web_contents_id = IdFromWebContents(web_contents); |
| + int64_t web_contents_id = TabManager::IdFromWebContents(web_contents); |
| if (web_contents_id == target_web_contents_id) { |
| *model = local_model; |
| return idx; |
| @@ -352,7 +346,7 @@ WebContents* TabManager::DiscardTabById(int64_t target_web_contents_id) { |
| WebContents* TabManager::DiscardTabByExtension(content::WebContents* contents) { |
| if (contents) |
| - return DiscardTabById(reinterpret_cast<int64_t>(contents)); |
| + return DiscardTabById(TabManager::IdFromWebContents(contents)); |
|
Georges Khalil
2016/08/16 21:18:29
nit: remove TabManager::
Anderson Silva
2016/08/16 21:37:51
Done.
|
| return DiscardTabImpl(); |
| } |
| @@ -465,6 +459,11 @@ bool TabManager::CompareTabStats(const TabStats& first, |
| return first.last_active > second.last_active; |
| } |
| +// static |
| +int64_t TabManager::IdFromWebContents(WebContents* web_contents) { |
| + return reinterpret_cast<int64_t>(web_contents); |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| // TabManager, private: |