| 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_SERVICE_H_ | 5 #ifndef IOS_CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| 6 #define IOS_CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 6 #define IOS_CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| 7 | 7 |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 | 11 |
| 12 namespace ios { | 12 namespace ios { |
| 13 class ChromeBrowserState; | 13 class ChromeBrowserState; |
| 14 } | 14 } |
| 15 | 15 |
| 16 @class SessionWindowIOS; | 16 @class SessionWindowIOS; |
| 17 | 17 |
| 18 // Trivial NSKeyedUnarchiver subclass that can be configured with a | 18 // Trivial NSKeyedUnarchiver subclass that can be configured with a |
| 19 // ChromeBrowserState instance that decoding classes can use. | 19 // ChromeBrowserState instance that decoding classes can use. |
| 20 @interface SessionWindowUnarchiver : NSKeyedUnarchiver | 20 @interface SessionWindowUnarchiver : NSKeyedUnarchiver |
| 21 | 21 |
| 22 // The BrowserState set on the unarchiver at init; a weak pointer. | 22 // The BrowserState set on the unarchiver at init; a weak pointer. |
| 23 @property(nonatomic, readonly) ios::ChromeBrowserState* browserState; | 23 @property(nonatomic, readonly) ios::ChromeBrowserState* browserState; |
| 24 | 24 |
| 25 // Inits exactly as initForReadingWithData: does, additionally setting | 25 // Inits exactly as initForReadingWithData: does, additionally setting |
| 26 // |browserState| on the receiver. | 26 // |browserState| on the receiver. |
| 27 - (instancetype)initForReadingWithData:(NSData*)data | 27 - (instancetype)initForReadingWithData:(NSData*)data |
| 28 browserState:(ios::ChromeBrowserState*)browserState; | 28 browserState:(ios::ChromeBrowserState*)browserState |
| 29 NS_DESIGNATED_INITIALIZER; |
| 29 | 30 |
| 30 @end | 31 @end |
| 31 | 32 |
| 32 // A singleton service for saving the current session. Can either save on a | 33 // A singleton service for saving the current session. Can either save on a |
| 33 // delay or immediately. Saving is always performed on a separate thread. | 34 // delay or immediately. Saving is always performed on a separate thread. |
| 34 @interface SessionServiceIOS : NSObject | 35 @interface SessionServiceIOS : NSObject |
| 35 | 36 |
| 36 // Lazily creates a singleton instance. Use this instead of calling alloc/init. | 37 // Lazily creates a singleton instance. Use this instead of calling alloc/init. |
| 37 + (SessionServiceIOS*)sharedService; | 38 + (SessionServiceIOS*)sharedService; |
| 38 | 39 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 58 // Loads the window from the given backup file on disk on the main thread. | 59 // Loads the window from the given backup file on disk on the main thread. |
| 59 // Returns nil if unable to read the sessions. | 60 // Returns nil if unable to read the sessions. |
| 60 - (SessionWindowIOS*)loadWindowFromPath:(NSString*)path | 61 - (SessionWindowIOS*)loadWindowFromPath:(NSString*)path |
| 61 forBrowserState:(ios::ChromeBrowserState*)browserState; | 62 forBrowserState:(ios::ChromeBrowserState*)browserState; |
| 62 | 63 |
| 63 // Returns the path of the session file. | 64 // Returns the path of the session file. |
| 64 - (NSString*)sessionFilePathForDirectory:(NSString*)directory; | 65 - (NSString*)sessionFilePathForDirectory:(NSString*)directory; |
| 65 | 66 |
| 66 @end | 67 @end |
| 67 | 68 |
| 69 @interface SessionServiceIOS (Testing) |
| 70 |
| 71 // For some of the unit tests, we need to make sure the session is saved |
| 72 // immediately so we can read it back in to verify various attributes. This |
| 73 // is not a situation we normally expect to be in because we never |
| 74 // want the session being saved on the main thread in the production app. |
| 75 - (void)performSaveWindow:(SessionWindowIOS*)window |
| 76 toDirectory:(NSString*)directory; |
| 77 |
| 78 @end |
| 79 |
| 68 #endif // IOS_CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 80 #endif // IOS_CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| OLD | NEW |