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

Side by Side Diff: chrome/common/spellcheck_marker.h

Issue 1619363002: Add compile time checks against longs being used in IPC structs on 32 bit Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more per Dmitry Created 4 years, 10 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #ifndef CHROME_COMMON_SPELLCHECK_MARKER_H_ 5 #ifndef CHROME_COMMON_SPELLCHECK_MARKER_H_
6 #define CHROME_COMMON_SPELLCHECK_MARKER_H_ 6 #define CHROME_COMMON_SPELLCHECK_MARKER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 class SpellCheckMarker { 11 class SpellCheckMarker {
12 public: 12 public:
13 // A predicate to test spellcheck marker validity. 13 // A predicate to test spellcheck marker validity.
14 class IsValidPredicate { 14 class IsValidPredicate {
15 public: 15 public:
16 typedef SpellCheckMarker argument_type; 16 typedef SpellCheckMarker argument_type;
17 explicit IsValidPredicate(size_t text_length) : text_length_(text_length) {} 17 explicit IsValidPredicate(size_t text_length) : text_length_(text_length) {}
18 bool operator()(const SpellCheckMarker& marker) const { 18 bool operator()(const SpellCheckMarker& marker) const {
19 return marker.offset < text_length_; 19 return marker.offset < text_length_;
20 } 20 }
21 private: 21 private:
22 size_t text_length_; 22 size_t text_length_;
23 }; 23 };
24 24
25 // IPC requires a default constructor. 25 // IPC requires a default constructor.
26 SpellCheckMarker() : hash(0xFFFFFFFF), offset(static_cast<size_t>(-1)) {} 26 SpellCheckMarker() : hash(0xFFFFFFFF), offset(UINT32_MAX) {}
27 27
28 SpellCheckMarker(uint32_t hash, size_t offset) : hash(hash), offset(offset) {} 28 SpellCheckMarker(uint32_t hash, uint32_t offset)
29 : hash(hash), offset(offset) {}
29 30
30 uint32_t hash; 31 uint32_t hash;
31 size_t offset; 32 uint32_t offset;
32 }; 33 };
33 34
34 #endif // CHROME_COMMON_SPELLCHECK_MARKER_H_ 35 #endif // CHROME_COMMON_SPELLCHECK_MARKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698