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

Unified Diff: content/browser/android/java/gin_java_script_to_java_types_coercion.cc

Issue 1471693006: Remove kint32min. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint3
Patch Set: rebase Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/java/gin_java_script_to_java_types_coercion.cc
diff --git a/content/browser/android/java/gin_java_script_to_java_types_coercion.cc b/content/browser/android/java/gin_java_script_to_java_types_coercion.cc
index b74775280e6d19784a5ef18716a601a8320e09f2..f65a96aea1832f13afe9a8c1a1989a83c1345297 100644
--- a/content/browser/android/java/gin_java_script_to_java_types_coercion.cc
+++ b/content/browser/android/java/gin_java_script_to_java_types_coercion.cc
@@ -7,6 +7,8 @@
#include <stdint.h>
#include <unistd.h>
+#include <limits>
+
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/strings/string_number_conversions.h"
@@ -34,19 +36,19 @@ double RoundDoubleTowardsZero(const double& x) {
// Rounds to jlong using Java's type conversion rules.
jlong RoundDoubleToLong(const double& x) {
double intermediate = RoundDoubleTowardsZero(x);
- // The int64 limits can not be converted exactly to double values, so we
+ // The int64_t limits can not be converted exactly to double values, so we
// compare to custom constants. kint64max is 2^63 - 1, but the spacing
// between double values in the the range 2^62 to 2^63 is 2^10. The cast is
// required to silence a spurious gcc warning for integer overflow.
- const int64 kLimit = (INT64_C(1) << 63) - static_cast<uint64>(1 << 10);
+ const int64_t kLimit = (INT64_C(1) << 63) - static_cast<uint64_t>(1 << 10);
DCHECK(kLimit > 0);
const double kLargestDoubleLessThanInt64Max = kLimit;
const double kSmallestDoubleGreaterThanInt64Min = -kLimit;
if (intermediate > kLargestDoubleLessThanInt64Max) {
- return kint64max;
+ return std::numeric_limits<int64_t>::max();
}
if (intermediate < kSmallestDoubleGreaterThanInt64Min) {
- return kint64min;
+ return std::numeric_limits<int64_t>::min();
}
return static_cast<jlong>(intermediate);
}
@@ -54,9 +56,11 @@ jlong RoundDoubleToLong(const double& x) {
// Rounds to jint using Java's type conversion rules.
jint RoundDoubleToInt(const double& x) {
double intermediate = RoundDoubleTowardsZero(x);
- // The int32 limits cast exactly to double values.
- intermediate = std::min(intermediate, static_cast<double>(kint32max));
- intermediate = std::max(intermediate, static_cast<double>(kint32min));
+ // The int32_t limits cast exactly to double values.
+ intermediate = std::min(
+ intermediate, static_cast<double>(std::numeric_limits<int32_t>::max()));
+ intermediate = std::max(
+ intermediate, static_cast<double>(std::numeric_limits<int32_t>::min()));
return static_cast<jint>(intermediate);
}
@@ -514,13 +518,14 @@ jobject CoerceJavaScriptDictionaryToArray(JNIEnv* env,
if (length_value->IsType(base::Value::TYPE_INTEGER)) {
int int_length;
length_value->GetAsInteger(&int_length);
- if (int_length >= 0 && int_length <= kint32max) {
+ if (int_length >= 0 && int_length <= std::numeric_limits<int32_t>::max()) {
length = static_cast<jsize>(int_length);
}
} else if (length_value->IsType(base::Value::TYPE_DOUBLE)) {
double double_length;
length_value->GetAsDouble(&double_length);
- if (double_length >= 0.0 && double_length <= kint32max) {
+ if (double_length >= 0.0 &&
+ double_length <= std::numeric_limits<int32_t>::max()) {
length = static_cast<jsize>(double_length);
}
}
« no previous file with comments | « chrome/renderer/instant_restricted_id_cache_unittest.cc ('k') | content/browser/geolocation/network_location_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698