Chromium Code Reviews| Index: ios/chrome/browser/tabs/legacy_tab_helper.h |
| diff --git a/ios/chrome/browser/tabs/legacy_tab_helper.h b/ios/chrome/browser/tabs/legacy_tab_helper.h |
| index 0ede4ffd921422d91d3f8db1ac8b7cdc4585d967..44045ffcad3c93b52ae06de71de3909df8a54d4b 100644 |
| --- a/ios/chrome/browser/tabs/legacy_tab_helper.h |
| +++ b/ios/chrome/browser/tabs/legacy_tab_helper.h |
| @@ -5,32 +5,32 @@ |
| #ifndef IOS_CHROME_BROWSER_TABS_LEGACY_TAB_HELPER_H_ |
| #define IOS_CHROME_BROWSER_TABS_LEGACY_TAB_HELPER_H_ |
| -#import "base/ios/weak_nsobject.h" |
| +#import "base/mac/scoped_nsobject.h" |
| #include "base/macros.h" |
| +#import "ios/web/public/web_state/web_state_observer.h" |
| #import "ios/web/public/web_state/web_state_user_data.h" |
| @class Tab; |
| -// LegacyTabHelper allows to access to the Tab owning a given WebState for |
| -// interoperability of code using WebStates with legacy code using Tabs. |
| -class LegacyTabHelper : public web::WebStateUserData<LegacyTabHelper> { |
| +// LegacyTabHelper associates a Tab instance to a WebState object. |
| +class LegacyTabHelper : public web::WebStateObserver, |
| + public web::WebStateUserData<LegacyTabHelper> { |
| public: |
| - // Creates the LegacyTabHelper to record the association of |web_state| |
| - // with |tab|. It is an error if |web_state| is already associated with |
| - // another Tab. |
| - static void CreateForWebState(web::WebState* web_state, Tab* tab); |
| + // Creates the LegacyTabHelper. This immediately creates the Tab object. |
| + static void CreateForWebState(web::WebState* web_state); |
| - // Returns the Tab associated with |web_state| if it exists or nil. |
| + // Returns the Tab associated with |web_state| or nil. |
| static Tab* GetTabForWebState(web::WebState* web_state); |
| private: |
| - LegacyTabHelper(web::WebState* web_state, Tab* tab); |
| + explicit LegacyTabHelper(web::WebState* web_state); |
| ~LegacyTabHelper() override; |
| - // The Tab instance associated with the WebState. The Tab currently owns |
| - // the WebState, so this should only be nil between the call to -[Tab close] |
| - // and the object is deallocated. |
| - base::WeakNSObject<Tab> tab_; |
| + // web::WebStateObserver implementation. |
| + void WebStateDestroyed() override; |
| + |
| + // The Tab instance associated with the WebState. |
|
rohitrao (ping after 24h)
2017/03/26 23:21:21
Should we document the lifetime of this Tab object
sdefresne
2017/03/28 15:15:05
Done in ios/chrome/browser/tabs/tab_lifecycle.md (
|
| + base::scoped_nsobject<Tab> tab_; |
| DISALLOW_COPY_AND_ASSIGN(LegacyTabHelper); |
| }; |