| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/memory/tab_manager.h" | 7 #include "chrome/browser/memory/tab_manager.h" |
| 8 #include "chrome/browser/memory/tab_manager_observer.h" | 8 #include "chrome/browser/memory/tab_manager_observer.h" |
| 9 #include "chrome/browser/memory/tab_manager_web_contents_data.h" | 9 #include "chrome/browser/memory/tab_manager_web_contents_data.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 int GetIndex(WebContents* contents) { | 31 int GetIndex(WebContents* contents) { |
| 32 return tab_strip_model_->GetIndexOfWebContents(contents); | 32 return tab_strip_model_->GetIndexOfWebContents(contents); |
| 33 } | 33 } |
| 34 | 34 |
| 35 WebContents* GetContents(int index) { | 35 WebContents* GetContents(int index) { |
| 36 return tab_strip_model_->GetWebContentsAt(index); | 36 return tab_strip_model_->GetWebContentsAt(index); |
| 37 } | 37 } |
| 38 | 38 |
| 39 int64_t ContentsId(WebContents* contents) { | 39 int64_t ContentsId(WebContents* contents) { |
| 40 return reinterpret_cast<int64_t>(contents); | 40 return TabManager::IdFromWebContents(contents); |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 TabStripModel* tab_strip_model_; | 44 TabStripModel* tab_strip_model_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class MockTabManagerObserver : public TabManagerObserver { | 47 class MockTabManagerObserver : public TabManagerObserver { |
| 48 public: | 48 public: |
| 49 MockTabManagerObserver() | 49 MockTabManagerObserver() |
| 50 : nb_events_(0), | 50 : nb_events_(0), |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // Change it back and we should have another event. | 179 // Change it back and we should have another event. |
| 180 tab_manager->SetTabAutoDiscardableState(contents, true); | 180 tab_manager->SetTabAutoDiscardableState(contents, true); |
| 181 EXPECT_EQ(2, observer.nb_events()); | 181 EXPECT_EQ(2, observer.nb_events()); |
| 182 EXPECT_TRUE(observer.is_auto_discardable()); | 182 EXPECT_TRUE(observer.is_auto_discardable()); |
| 183 EXPECT_EQ(ContentsId(contents), ContentsId(observer.content())); | 183 EXPECT_EQ(ContentsId(contents), ContentsId(observer.content())); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace memory | 186 } // namespace memory |
| 187 | 187 |
| 188 #endif // OS_WIN || OS_MAXOSX || OS_LINUX | 188 #endif // OS_WIN || OS_MAXOSX || OS_LINUX |
| OLD | NEW |