OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/test_session_service.h" | 5 #import "ios/chrome/browser/sessions/test_session_service.h" |
6 | 6 |
| 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 |
7 #if !defined(__has_feature) || !__has_feature(objc_arc) | 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
8 #error "This file requires ARC support." | 11 #error "This file requires ARC support." |
9 #endif | 12 #endif |
10 | 13 |
11 @implementation TestSessionService | 14 @implementation TestSessionService |
12 - (void)saveWindow:(SessionWindowIOS*)window | 15 |
13 forBrowserState:(ios::ChromeBrowserState*)browserState | 16 @synthesize performIO = _performIO; |
14 immediately:(BOOL)immediately { | 17 |
15 [NSKeyedArchiver archivedDataWithRootObject:window]; | 18 - (instancetype)init { |
| 19 return [super initWithTaskRunner:base::ThreadTaskRunnerHandle::Get()]; |
16 } | 20 } |
| 21 |
| 22 - (void)saveSessionWindow:(SessionWindowIOS*)sessionWindow |
| 23 directory:(NSString*)directory |
| 24 immediately:(BOOL)immediately { |
| 25 NSString* sessionPath = [[self class] sessionPathForDirectory:directory]; |
| 26 NSData* data = [NSKeyedArchiver archivedDataWithRootObject:sessionWindow]; |
| 27 if (self.performIO) |
| 28 [self performSaveSessionData:data sessionPath:sessionPath]; |
| 29 } |
| 30 |
17 @end | 31 @end |
OLD | NEW |