Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: ios/chrome/browser/sessions/session_service_ios.h

Issue 2810743002: [ios] Refactor SessionServiceIOS to remove dependency on BrowserState. (Closed)
Patch Set: Fix a typo in SessionServiceIOS initializer's comment. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/sessions/BUILD.gn ('k') | ios/chrome/browser/sessions/session_service_ios.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/sessions/session_service_ios.h
diff --git a/ios/chrome/browser/sessions/session_service_ios.h b/ios/chrome/browser/sessions/session_service_ios.h
index 197394999aba646b16146c0eb280686af489ac4d..ae3b99d60c5075b14e4e473651fb9ed81a2daa1c 100644
--- a/ios/chrome/browser/sessions/session_service_ios.h
+++ b/ios/chrome/browser/sessions/session_service_ios.h
@@ -7,9 +7,7 @@
#import <Foundation/Foundation.h>
-namespace ios {
-class ChromeBrowserState;
-}
+#include "base/sequenced_task_runner.h"
@class SessionWindowIOS;
@@ -17,45 +15,48 @@ class ChromeBrowserState;
// delay or immediately. Saving is always performed on a separate thread.
@interface SessionServiceIOS : NSObject
-// Lazily creates a singleton instance. Use this instead of calling alloc/init.
+// Lazily creates a singleton instance with a default task runner.
+ (SessionServiceIOS*)sharedService;
-// Saves the session represented by |window| to the given browserState directory
-// on disk. If |immediately| is NO, the save is done after a delay. If another
-// call is pending, this one is ignored. If YES, the save is done now,
-// cancelling any pending calls. Either way, the save is done on a separate
-// thread to avoid blocking the UI thread. As a result, |window| should contain
-// copies of non-threadsafe objects.
-- (void)saveWindow:(SessionWindowIOS*)window
- forBrowserState:(ios::ChromeBrowserState*)browserState
- immediately:(BOOL)immediately;
+// Initializes a SessionServiceIOS with a given task runner. Prefer to use the
+// |sharedService| method.
+- (instancetype)initWithTaskRunner:
+ (const scoped_refptr<base::SequencedTaskRunner>&)taskRunner
+ NS_DESIGNATED_INITIALIZER;
-// Loads the window from the given browserState directory on disk on the main
-// thread. Returns nil if no session was previously saved.
-- (SessionWindowIOS*)loadWindowForBrowserState:
- (ios::ChromeBrowserState*)browserState;
+// Saves the session represented by |sessionWindow| to |directory| on disk. If
+// |immediately| is NO, the save is done after a delay. If another call is
+// pending, this one is ignored. If YES, the save is done now, cancelling any
+// pending calls. Either way, the save is done on a separate thread to avoid
+// blocking the UI thread.
+- (void)saveSessionWindow:(SessionWindowIOS*)sessionWindow
+ directory:(NSString*)directory
+ immediately:(BOOL)immediately;
-// Schedules deletion of the file containing the commands for the last session
-// in the given browserState directory.
-- (void)deleteLastSession:(NSString*)directory;
+// Loads the session window from default session file in |directory| on the
+// main thread. Returns nil in case of errors.
+- (SessionWindowIOS*)loadSessionWindowFromDirectory:(NSString*)directory;
-// Loads the window from the given backup file on disk on the main thread.
-// Returns nil if unable to read the sessions.
-- (SessionWindowIOS*)loadWindowFromPath:(NSString*)sessionPath;
+// Loads the session window from |sessionPath| on the main thread. Returns nil
+// in case of errors.
+- (SessionWindowIOS*)loadSessionWindowFromPath:(NSString*)sessionPath;
-// Returns the path of the session file.
-- (NSString*)sessionFilePathForDirectory:(NSString*)directory;
+// Schedules deletion of the file containing the last session in |directory|.
+- (void)deleteLastSessionFileInDirectory:(NSString*)directory;
+
+// Returns the path of the session file for |directory|.
++ (NSString*)sessionPathForDirectory:(NSString*)directory;
@end
-@interface SessionServiceIOS (Testing)
+@interface SessionServiceIOS (SubClassing)
// For some of the unit tests, we need to make sure the session is saved
// immediately so we can read it back in to verify various attributes. This
// is not a situation we normally expect to be in because we never
// want the session being saved on the main thread in the production app.
-- (void)performSaveWindow:(SessionWindowIOS*)window
- toDirectory:(NSString*)directory;
+- (void)performSaveSessionData:(NSData*)sessionData
+ sessionPath:(NSString*)sessionPath;
@end
« no previous file with comments | « ios/chrome/browser/sessions/BUILD.gn ('k') | ios/chrome/browser/sessions/session_service_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698