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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/mac/bind_objc_block.h" | 12 #include "base/mac/bind_objc_block.h" |
13 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
16 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
19 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
21 #import "ios/chrome/browser/sessions/session_window.h" | 21 #import "ios/chrome/browser/sessions/session_window.h" |
22 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" | 22 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" |
23 #import "ios/web/navigation/crw_session_controller.h" | 23 #import "ios/web/public/crw_navigation_item_storage.h" |
24 #import "ios/web/navigation/crw_session_entry.h" | |
25 #import "ios/web/public/crw_navigation_manager_storage.h" | 24 #import "ios/web/public/crw_navigation_manager_storage.h" |
26 #include "ios/web/public/web_thread.h" | 25 #include "ios/web/public/web_thread.h" |
27 | 26 |
28 // When C++ exceptions are disabled, the C++ library defines |try| and | 27 // When C++ exceptions are disabled, the C++ library defines |try| and |
29 // |catch| so as to allow exception-expecting C++ code to build properly when | 28 // |catch| so as to allow exception-expecting C++ code to build properly when |
30 // language support for exceptions is not present. These macros interfere | 29 // language support for exceptions is not present. These macros interfere |
31 // with the use of |@try| and |@catch| in Objective-C files such as this one. | 30 // with the use of |@try| and |@catch| in Objective-C files such as this one. |
32 // Undefine these macros here, after everything has been #included, since | 31 // Undefine these macros here, after everything has been #included, since |
33 // there will be no C++ uses and only Objective-C uses from this point on. | 32 // there will be no C++ uses and only Objective-C uses from this point on. |
34 #undef try | 33 #undef try |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 - (SessionWindowIOS*)loadWindowFromPath:(NSString*)path | 208 - (SessionWindowIOS*)loadWindowFromPath:(NSString*)path |
210 forBrowserState:(ios::ChromeBrowserState*)browserState { | 209 forBrowserState:(ios::ChromeBrowserState*)browserState { |
211 // HACK: Handle the case where we had to change the class name of a persisted | 210 // HACK: Handle the case where we had to change the class name of a persisted |
212 // class on disk. | 211 // class on disk. |
213 [SessionWindowUnarchiver setClass:[CRWSessionCertificatePolicyManager class] | 212 [SessionWindowUnarchiver setClass:[CRWSessionCertificatePolicyManager class] |
214 forClassName:@"SessionCertificatePolicyManager"]; | 213 forClassName:@"SessionCertificatePolicyManager"]; |
215 [SessionWindowUnarchiver setClass:[CRWNavigationManagerStorage class] | 214 [SessionWindowUnarchiver setClass:[CRWNavigationManagerStorage class] |
216 forClassName:@"SessionController"]; | 215 forClassName:@"SessionController"]; |
217 [SessionWindowUnarchiver setClass:[CRWNavigationManagerStorage class] | 216 [SessionWindowUnarchiver setClass:[CRWNavigationManagerStorage class] |
218 forClassName:@"CRWSessionController"]; | 217 forClassName:@"CRWSessionController"]; |
219 [SessionWindowUnarchiver setClass:[CRWSessionEntry class] | 218 [SessionWindowUnarchiver setClass:[CRWNavigationItemStorage class] |
220 forClassName:@"SessionEntry"]; | 219 forClassName:@"SessionEntry"]; |
| 220 [SessionWindowUnarchiver setClass:[CRWNavigationItemStorage class] |
| 221 forClassName:@"CRWSessionEntry"]; |
221 // TODO(crbug.com/661633): Remove this hack. | 222 // TODO(crbug.com/661633): Remove this hack. |
222 [SessionWindowUnarchiver setClass:[SessionWindowIOS class] | 223 [SessionWindowUnarchiver setClass:[SessionWindowIOS class] |
223 forClassName:@"SessionWindow"]; | 224 forClassName:@"SessionWindow"]; |
224 SessionWindowIOS* window = nil; | 225 SessionWindowIOS* window = nil; |
225 @try { | 226 @try { |
226 NSData* data = [NSData dataWithContentsOfFile:path]; | 227 NSData* data = [NSData dataWithContentsOfFile:path]; |
227 if (data) { | 228 if (data) { |
228 base::scoped_nsobject<SessionWindowUnarchiver> unarchiver([ | 229 base::scoped_nsobject<SessionWindowUnarchiver> unarchiver([ |
229 [SessionWindowUnarchiver alloc] initForReadingWithData:data | 230 [SessionWindowUnarchiver alloc] initForReadingWithData:data |
230 browserState:browserState]); | 231 browserState:browserState]); |
(...skipping 14 matching lines...) Expand all Loading... |
245 base::ThreadRestrictions::AssertIOAllowed(); | 246 base::ThreadRestrictions::AssertIOAllowed(); |
246 NSFileManager* fileManager = [NSFileManager defaultManager]; | 247 NSFileManager* fileManager = [NSFileManager defaultManager]; |
247 if (![fileManager fileExistsAtPath:sessionFile]) | 248 if (![fileManager fileExistsAtPath:sessionFile]) |
248 return; | 249 return; |
249 if (![fileManager removeItemAtPath:sessionFile error:nil]) | 250 if (![fileManager removeItemAtPath:sessionFile error:nil]) |
250 CHECK(false) << "Unable to delete session file."; | 251 CHECK(false) << "Unable to delete session file."; |
251 })); | 252 })); |
252 } | 253 } |
253 | 254 |
254 @end | 255 @end |
OLD | NEW |