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

Side by Side Diff: ios/chrome/browser/sessions/NSCoder+Compatibility.mm

Issue 2808773004: [ios] Change WebStateList serialization method to use SessionWindowIOS. (Closed)
Patch Set: Rename //ios/chrome/browser/sessions:session_window_ios target. 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 unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/sessions/BUILD.gn ('k') | ios/chrome/browser/sessions/session_util.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/NSCoder+Compatibility.h" 5 #import "ios/chrome/browser/sessions/NSCoder+Compatibility.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support."
11 #endif
12
9 namespace { 13 namespace {
10 // Note: |NSNotFound| is equal to |NSIntegerMax| in 32-bit and 64-bit that 14 // Note: |NSNotFound| is equal to |NSIntegerMax| in 32-bit and 64-bit that
11 // in turn is initialized to |LONG_MAX|. On a 32-bit build, |INT_MAX| and 15 // in turn is initialized to |LONG_MAX|. On a 32-bit build, |INT_MAX| and
12 // |LONG_MAX| have the same value, however, in a 64-bit build, |LONG_MAX| 16 // |LONG_MAX| have the same value, however, in a 64-bit build, |LONG_MAX|
13 // is much larger, so we define |NSNotFound32| to |INT_MAX| that has the 17 // is much larger, so we define |NSNotFound32| to |INT_MAX| that has the
14 // same value in both 32-bit and 64-bit builds. 18 // same value in both 32-bit and 64-bit builds.
15 enum { NSNotFound32 = INT_MAX }; 19 enum { NSNotFound32 = INT_MAX };
16 } // namespace 20 } // namespace
17 21
18 @implementation NSCoder (Compatibility) 22 @implementation NSCoder (Compatibility)
19 23
20 - (NSInteger)cr_decodeIndexForKey:(NSString*)key { 24 - (NSInteger)cr_decodeIndexForKey:(NSString*)key {
21 int32_t index32 = [self decodeInt32ForKey:key]; 25 int32_t index32 = [self decodeInt32ForKey:key];
22 DCHECK(0 <= index32 && index32 <= NSNotFound32); 26 DCHECK(0 <= index32 && index32 <= NSNotFound32);
23 return index32 == NSNotFound32 ? NSNotFound : static_cast<NSInteger>(index32); 27 return index32 == NSNotFound32 ? NSNotFound : static_cast<NSInteger>(index32);
24 } 28 }
25 29
26 - (void)cr_encodeIndex:(NSInteger)index forKey:(NSString*)key { 30 - (void)cr_encodeIndex:(NSInteger)index forKey:(NSString*)key {
27 DCHECK((0 <= index && index < NSNotFound32) || index == NSNotFound); 31 DCHECK((0 <= index && index < NSNotFound32) || index == NSNotFound);
28 int32_t index32 = index == NSNotFound ? static_cast<int32_t>(NSNotFound32) 32 int32_t index32 = index == NSNotFound ? static_cast<int32_t>(NSNotFound32)
29 : static_cast<int32_t>(index); 33 : static_cast<int32_t>(index);
30 [self encodeInt32:index32 forKey:key]; 34 [self encodeInt32:index32 forKey:key];
31 } 35 }
32 36
33 @end 37 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/sessions/BUILD.gn ('k') | ios/chrome/browser/sessions/session_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698