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

Side by Side Diff: net/quic/chromium/quic_utils_chromium.h

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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 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 // Some helpers for quic that are for chromium codebase. 5 // Some helpers for quic that are for chromium codebase.
6 6
7 #ifndef NET_QUIC_CHROMIUM_QUIC_UTILS_CHROMIUM_H_ 7 #ifndef NET_QUIC_CHROMIUM_QUIC_UTILS_CHROMIUM_H_
8 #define NET_QUIC_CHROMIUM_QUIC_UTILS_CHROMIUM_H_ 8 #define NET_QUIC_CHROMIUM_QUIC_UTILS_CHROMIUM_H_
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 17 matching lines...) Expand all
28 // * It invalidates iterators (when it chooses to resize) 28 // * It invalidates iterators (when it chooses to resize)
29 // * It default constructs a value object even if it doesn't need to 29 // * It default constructs a value object even if it doesn't need to
30 // 30 //
31 // This version assumes the key is printable, and includes it in the fatal log 31 // This version assumes the key is printable, and includes it in the fatal log
32 // message. 32 // message.
33 template <class Collection> 33 template <class Collection>
34 const typename Collection::value_type::second_type& FindOrDie( 34 const typename Collection::value_type::second_type& FindOrDie(
35 const Collection& collection, 35 const Collection& collection,
36 const typename Collection::value_type::first_type& key) { 36 const typename Collection::value_type::first_type& key) {
37 typename Collection::const_iterator it = collection.find(key); 37 typename Collection::const_iterator it = collection.find(key);
38 CHECK(it != collection.end()) << "Map key not found: " << key; 38 // Map key not found.
39 CHECK(it != collection.end());
39 return it->second; 40 return it->second;
40 } 41 }
41 42
42 // Same as above, but returns a non-const reference. 43 // Same as above, but returns a non-const reference.
43 template <class Collection> 44 template <class Collection>
44 typename Collection::value_type::second_type& FindOrDie( 45 typename Collection::value_type::second_type& FindOrDie(
45 Collection& collection, // NOLINT 46 Collection& collection, // NOLINT
46 const typename Collection::value_type::first_type& key) { 47 const typename Collection::value_type::first_type& key) {
47 typename Collection::iterator it = collection.find(key); 48 typename Collection::iterator it = collection.find(key);
48 CHECK(it != collection.end()) << "Map key not found: " << key; 49 // Map key not found.
50 CHECK(it != collection.end());
49 return it->second; 51 return it->second;
50 } 52 }
51 53
52 // Returns a pointer to the const value associated with the given key if it 54 // Returns a pointer to the const value associated with the given key if it
53 // exists, or NULL otherwise. 55 // exists, or NULL otherwise.
54 template <class Collection> 56 template <class Collection>
55 const typename Collection::value_type::second_type* FindOrNull( 57 const typename Collection::value_type::second_type* FindOrNull(
56 const Collection& collection, 58 const Collection& collection,
57 const typename Collection::value_type::first_type& key) { 59 const typename Collection::value_type::first_type& key) {
58 typename Collection::const_iterator it = collection.find(key); 60 typename Collection::const_iterator it = collection.find(key);
(...skipping 11 matching lines...) Expand all
70 typename Collection::iterator it = collection.find(key); 72 typename Collection::iterator it = collection.find(key);
71 if (it == collection.end()) { 73 if (it == collection.end()) {
72 return 0; 74 return 0;
73 } 75 }
74 return &it->second; 76 return &it->second;
75 } 77 }
76 78
77 } // namespace net 79 } // namespace net
78 80
79 #endif // NET_QUIC_CHROMIUM_QUIC_UTILS_CHROMIUM_H_ 81 #endif // NET_QUIC_CHROMIUM_QUIC_UTILS_CHROMIUM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698