Chromium Code Reviews| 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 return (length + g_chunk_max_length_ - 1) / g_chunk_max_length_; |
|
brettw
2014/10/01 17:54:06
I felt like the intent of the old code was clearer
Peter Kasting
2014/10/01 19:30:21
We can cast the result, but if something is unclea
| |
| 40 } | 40 } |
| 41 | 41 |
| 42 // The longest max_length allowed by the system. | 42 // The longest max_length allowed by the system. |
| 43 const size_t kLargestValueAllowed = 1024; | 43 const size_t kLargestValueAllowed = 1024; |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 void SetCrashKeyValue(const base::StringPiece& key, | 47 void SetCrashKeyValue(const base::StringPiece& key, |
| 48 const base::StringPiece& value) { | 48 const base::StringPiece& value) { |
| 49 if (!g_set_key_func_ || !g_crash_keys_) | 49 if (!g_set_key_func_ || !g_crash_keys_) |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 void ResetCrashLoggingForTesting() { | 193 void ResetCrashLoggingForTesting() { |
| 194 delete g_crash_keys_; | 194 delete g_crash_keys_; |
| 195 g_crash_keys_ = NULL; | 195 g_crash_keys_ = NULL; |
| 196 g_chunk_max_length_ = 0; | 196 g_chunk_max_length_ = 0; |
| 197 g_set_key_func_ = NULL; | 197 g_set_key_func_ = NULL; |
| 198 g_clear_key_func_ = NULL; | 198 g_clear_key_func_ = NULL; |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace debug | 201 } // namespace debug |
| 202 } // namespace base | 202 } // namespace base |
| OLD | NEW |