| 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 #import "ios/chrome/browser/sessions/session_service.h" | 5 #import "ios/chrome/browser/sessions/session_service.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // replaced. | 181 // replaced. |
| 182 SessionWindowIOS* pendingSession = base::mac::ObjCCast<SessionWindowIOS>( | 182 SessionWindowIOS* pendingSession = base::mac::ObjCCast<SessionWindowIOS>( |
| 183 [pendingWindows_ objectForKey:stashPath]); | 183 [pendingWindows_ objectForKey:stashPath]); |
| 184 [pendingSession clearSessions]; | 184 [pendingSession clearSessions]; |
| 185 // Set |window| as the pending save for |stashPath|. | 185 // Set |window| as the pending save for |stashPath|. |
| 186 [pendingWindows_ setObject:window forKey:stashPath]; | 186 [pendingWindows_ setObject:window forKey:stashPath]; |
| 187 if (immediately) { | 187 if (immediately) { |
| 188 [NSObject cancelPreviousPerformRequestsWithTarget:self]; | 188 [NSObject cancelPreviousPerformRequestsWithTarget:self]; |
| 189 [self performSaveToDirectoryInBackground:stashPath]; | 189 [self performSaveToDirectoryInBackground:stashPath]; |
| 190 } else if (!pendingSession) { | 190 } else if (!pendingSession) { |
| 191 // If there wasn't previously a delayed save pending for |stashPath}|, | 191 // If there wasn't previously a delayed save pending for |stashPath|, |
| 192 // enqueue one now. | 192 // enqueue one now. |
| 193 [self performSelector:@selector(performSaveToDirectoryInBackground:) | 193 [self performSelector:@selector(performSaveToDirectoryInBackground:) |
| 194 withObject:stashPath | 194 withObject:stashPath |
| 195 afterDelay:kSaveDelay]; | 195 afterDelay:kSaveDelay]; |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 - (SessionWindowIOS*)loadWindowForBrowserState: | 199 - (SessionWindowIOS*)loadWindowForBrowserState: |
| 200 (ios::ChromeBrowserState*)browserState { | 200 (ios::ChromeBrowserState*)browserState { |
| 201 NSString* stashPath = | 201 NSString* stashPath = |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 base::ThreadRestrictions::AssertIOAllowed(); | 245 base::ThreadRestrictions::AssertIOAllowed(); |
| 246 NSFileManager* fileManager = [NSFileManager defaultManager]; | 246 NSFileManager* fileManager = [NSFileManager defaultManager]; |
| 247 if (![fileManager fileExistsAtPath:sessionFile]) | 247 if (![fileManager fileExistsAtPath:sessionFile]) |
| 248 return; | 248 return; |
| 249 if (![fileManager removeItemAtPath:sessionFile error:nil]) | 249 if (![fileManager removeItemAtPath:sessionFile error:nil]) |
| 250 CHECK(false) << "Unable to delete session file."; | 250 CHECK(false) << "Unable to delete session file."; |
| 251 })); | 251 })); |
| 252 } | 252 } |
| 253 | 253 |
| 254 @end | 254 @end |
| OLD | NEW |