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

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

Issue 2810743002: [ios] Refactor SessionServiceIOS to remove dependency on BrowserState. (Closed)
Patch Set: Rebase. 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
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..2b711da42a1334224cea23494d702d8dd8f48afc 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,34 +15,35 @@ 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;
-
-// 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;
+// Initialize a SessionServiceIOS with a given task runner. Prefer to use the
+// |sharedService| method.
+- (instancetype)initWithTaskRunner:
+ (const scoped_refptr<base::SequencedTaskRunner>&)taskRunner
+ NS_DESIGNATED_INITIALIZER;
+
+// Saves the session represented by |sessionWindow| to |sessionPath| 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, |sessionWindow| should contain copies
marq (ping after 24h) 2017/04/11 10:46:29 Should, or could? Or shouldn't?
sdefresne 2017/04/11 11:49:41 Removed as the object is now only accessed on the
+// of non-threadsafe objects.
+- (void)saveSessionWindow:(SessionWindowIOS*)sessionWindow
+ sessionPath:(NSString*)sessionPath
+ immediately:(BOOL)immediately;
+
+// Loads the session window from the given file on disk on the main thread.
+// Returns nil in case of errors.
+- (SessionWindowIOS*)loadSessionWindowFromPath:(NSString*)sessionPath;
// Schedules deletion of the file containing the commands for the last session
-// in the given browserState directory.
-- (void)deleteLastSession:(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;
+// at the given path.
+- (void)deleteLastSessionAtPath:(NSString*)sessionPath;
// Returns the path of the session file.
-- (NSString*)sessionFilePathForDirectory:(NSString*)directory;
+- (NSString*)sessionPathForDirectory:(NSString*)directory;
@end
@@ -54,8 +53,8 @@ class ChromeBrowserState;
// 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
marq (ping after 24h) 2017/04/11 10:46:29 Can we remove the need for this by running tests o
sdefresne 2017/04/11 11:49:41 Updated the tests to not use this method. I still
+ sessionPath:(NSString*)sessionPath;
@end

Powered by Google App Engine
This is Rietveld 408576698