| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef IOS_CHROME_BROWSER_SESSIONS_SESSION_WINDOW_H_ | 5 #ifndef IOS_CHROME_BROWSER_SESSIONS_SESSION_WINDOW_H_ |
| 6 #define IOS_CHROME_BROWSER_SESSIONS_SESSION_WINDOW_H_ | 6 #define IOS_CHROME_BROWSER_SESSIONS_SESSION_WINDOW_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #import "ios/web/web_state/web_state_impl.h" | 12 #import "ios/web/web_state/web_state_impl.h" |
| 13 | 13 |
| 14 @class CRWNavigationManagerStorage; |
| 15 |
| 14 // Encapsulates everything required to save a session "window". For iOS, there | 16 // Encapsulates everything required to save a session "window". For iOS, there |
| 15 // will only be one window at a time. | 17 // will only be one window at a time. |
| 16 @interface SessionWindowIOS : NSObject<NSCoding> | 18 @interface SessionWindowIOS : NSObject<NSCoding> |
| 17 | 19 |
| 18 // So that ownership transfer of WebStateImpls is explicit, SessionWindows | 20 // Adds a serialized session to be written to disk. SessionWindows are |
| 19 // are initialized "empty" (without any sessions) and sessions are added | 21 // initialized "empty" (without any sessions) and sessions are added one at a |
| 20 // one at a time. For example: | 22 // time. For example: |
| 21 // SessionWindowIOS* window = [[SessionWindow alloc] init]; | 23 // SessionWindowIOS* window = [[SessionWindow alloc] init]; |
| 22 // [window addSession:some_scoped_webstate_ptr.Pass()]; | 24 // [window addSession:session_storage]; |
| 23 // ... | 25 // ... |
| 24 // [window setSelectedInex:mySelectedIndex]; | 26 // [window setSelectedInex:mySelectedIndex]; |
| 25 - (void)addSession:(std::unique_ptr<web::WebStateImpl>)session; | 27 - (void)addSerializedSession:(CRWNavigationManagerStorage*)session; |
| 26 | 28 |
| 29 // Clears all added sessions. |
| 27 - (void)clearSessions; | 30 - (void)clearSessions; |
| 28 | 31 |
| 29 // Takes the first session stored in the reciever, removes it and passes | 32 // The serialized session objects. |
| 30 // ownership of it to the caller. | 33 @property(nonatomic, readonly) NSArray* sessions; |
| 31 - (std::unique_ptr<web::WebStateImpl>)nextSession; | |
| 32 | 34 |
| 33 // The currently selected session. NSNotFound if the sessionWindow contains | 35 // The currently selected session. NSNotFound if the sessionWindow contains |
| 34 // no sessions; otherwise 0 <= |selectedIndex| < |unclaimedSessions|. | 36 // no sessions; otherwise 0 <= |selectedIndex| < |unclaimedSessions|. |
| 35 @property(nonatomic) NSUInteger selectedIndex; | 37 @property(nonatomic) NSUInteger selectedIndex; |
| 36 // A count of the remaining sessions that haven't been claimed. | |
| 37 @property(nonatomic, readonly) NSUInteger unclaimedSessions; | |
| 38 | 38 |
| 39 @end | 39 @end |
| 40 | 40 |
| 41 #endif // IOS_CHROME_BROWSER_SESSIONS_SESSION_WINDOW_H_ | 41 #endif // IOS_CHROME_BROWSER_SESSIONS_SESSION_WINDOW_H_ |
| OLD | NEW |