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

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

Issue 2585233003: Upstream Chrome on iOS source code [2/11]. (Closed)
Patch Set: Created 3 years, 12 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/sessions/NSCoder+Compatibility.h"
6
7 #include "base/logging.h"
8
9 namespace {
10 // 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
12 // |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
14 // same value in both 32-bit and 64-bit builds.
15 enum { NSNotFound32 = INT_MAX };
16 } // namespace
17
18 @implementation NSCoder (Compatibility)
19
20 - (NSInteger)cr_decodeIndexForKey:(NSString*)key {
21 int32_t index32 = [self decodeInt32ForKey:key];
22 DCHECK(0 <= index32 && index32 <= NSNotFound32);
23 return index32 == NSNotFound32 ? NSNotFound : static_cast<NSInteger>(index32);
24 }
25
26 - (void)cr_encodeIndex:(NSInteger)index forKey:(NSString*)key {
27 DCHECK((0 <= index && index < NSNotFound32) || index == NSNotFound);
28 int32_t index32 = index == NSNotFound ? static_cast<int32_t>(NSNotFound32)
29 : static_cast<int32_t>(index);
30 [self encodeInt32:index32 forKey:key];
31 }
32
33 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/sessions/NSCoder+Compatibility.h ('k') | ios/chrome/browser/sessions/session_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698