OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "base/debug/crash_logging.h" | 5 #include "base/debug/crash_logging.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/debug/stack_trace.h" | 10 #include "base/debug/stack_trace.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 const char kChunkFormatString[] = "%s-%" PRIuS; | 29 const char kChunkFormatString[] = "%s-%" PRIuS; |
30 | 30 |
31 // The functions that are called to actually set the key-value pairs in the | 31 // The functions that are called to actually set the key-value pairs in the |
32 // crash reportng system. | 32 // crash reportng system. |
33 SetCrashKeyValueFuncT g_set_key_func_ = NULL; | 33 SetCrashKeyValueFuncT g_set_key_func_ = NULL; |
34 ClearCrashKeyValueFuncT g_clear_key_func_ = NULL; | 34 ClearCrashKeyValueFuncT g_clear_key_func_ = NULL; |
35 | 35 |
36 // For a given |length|, computes the number of chunks a value of that size | 36 // For a given |length|, computes the number of chunks a value of that size |
37 // will occupy. | 37 // will occupy. |
38 size_t NumChunksForLength(size_t length) { | 38 size_t NumChunksForLength(size_t length) { |
39 return std::ceil(length / static_cast<float>(g_chunk_max_length_)); | 39 // Compute (length / g_chunk_max_length_), rounded up. |
| 40 return (length + g_chunk_max_length_ - 1) / g_chunk_max_length_; |
40 } | 41 } |
41 | 42 |
42 // The longest max_length allowed by the system. | 43 // The longest max_length allowed by the system. |
43 const size_t kLargestValueAllowed = 1024; | 44 const size_t kLargestValueAllowed = 1024; |
44 | 45 |
45 } // namespace | 46 } // namespace |
46 | 47 |
47 void SetCrashKeyValue(const base::StringPiece& key, | 48 void SetCrashKeyValue(const base::StringPiece& key, |
48 const base::StringPiece& value) { | 49 const base::StringPiece& value) { |
49 if (!g_set_key_func_ || !g_crash_keys_) | 50 if (!g_set_key_func_ || !g_crash_keys_) |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 void ResetCrashLoggingForTesting() { | 194 void ResetCrashLoggingForTesting() { |
194 delete g_crash_keys_; | 195 delete g_crash_keys_; |
195 g_crash_keys_ = NULL; | 196 g_crash_keys_ = NULL; |
196 g_chunk_max_length_ = 0; | 197 g_chunk_max_length_ = 0; |
197 g_set_key_func_ = NULL; | 198 g_set_key_func_ = NULL; |
198 g_clear_key_func_ = NULL; | 199 g_clear_key_func_ = NULL; |
199 } | 200 } |
200 | 201 |
201 } // namespace debug | 202 } // namespace debug |
202 } // namespace base | 203 } // namespace base |
OLD | NEW |