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