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

Side by Side Diff: Source/bindings/v8/custom/V8GeolocationCustom.cpp

Issue 285673002: Change value type of timeout and maximumAge in PositionOptions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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 /* 1 /*
2 * Copyright 2009, The Android Open Source Project 2 * Copyright 2009, The Android Open Source Project
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 if (!timeoutValue->IsUndefined()) { 79 if (!timeoutValue->IsUndefined()) {
80 v8::Local<v8::Number> timeoutNumber = timeoutValue->ToNumber(); 80 v8::Local<v8::Number> timeoutNumber = timeoutValue->ToNumber();
81 if (timeoutNumber.IsEmpty()) { 81 if (timeoutNumber.IsEmpty()) {
82 succeeded = false; 82 succeeded = false;
83 return nullptr; 83 return nullptr;
84 } 84 }
85 double timeoutDouble = timeoutNumber->Value(); 85 double timeoutDouble = timeoutNumber->Value();
86 // If the value is positive infinity, there's nothing to do. 86 // If the value is positive infinity, there's nothing to do.
87 if (!(std::isinf(timeoutDouble) && timeoutDouble > 0)) { 87 if (!(std::isinf(timeoutDouble) && timeoutDouble > 0)) {
88 v8::Local<v8::Int32> timeoutInt32 = timeoutValue->ToInt32(); 88 v8::Local<v8::Uint32> timeoutUint32 = timeoutValue->ToUint32();
89 if (timeoutInt32.IsEmpty()) { 89 if (timeoutUint32.IsEmpty()) {
90 succeeded = false; 90 succeeded = false;
91 return nullptr; 91 return nullptr;
92 } 92 }
93 // Wrap to int32 and force non-negative to match behavior of window. setTimeout. 93 // Wrap to int32 and force non-negative to match behavior of window. setTimeout.
Michael van Ouwerkerk 2014/05/13 16:15:17 Update this comment.
kihong 2014/05/14 03:44:25 Done.
94 options->setTimeout(max(0, timeoutInt32->Value())); 94 options->setTimeout(std::max<unsigned>(0, timeoutUint32->Value()));
Michael van Ouwerkerk 2014/05/13 16:15:17 The specification specifies [Clamp] so that overfl
95 } 95 }
96 } 96 }
97 97
98 v8::Local<v8::Value> maximumAgeValue = object->Get(v8AtomicString(isolate, " maximumAge")); 98 v8::Local<v8::Value> maximumAgeValue = object->Get(v8AtomicString(isolate, " maximumAge"));
99 if (maximumAgeValue.IsEmpty()) { 99 if (maximumAgeValue.IsEmpty()) {
100 succeeded = false; 100 succeeded = false;
101 return nullptr; 101 return nullptr;
102 } 102 }
103 if (!maximumAgeValue->IsUndefined()) { 103 if (!maximumAgeValue->IsUndefined()) {
104 v8::Local<v8::Number> maximumAgeNumber = maximumAgeValue->ToNumber(); 104 v8::Local<v8::Number> maximumAgeNumber = maximumAgeValue->ToNumber();
105 if (maximumAgeNumber.IsEmpty()) { 105 if (maximumAgeNumber.IsEmpty()) {
106 succeeded = false; 106 succeeded = false;
107 return nullptr; 107 return nullptr;
108 } 108 }
109 double maximumAgeDouble = maximumAgeNumber->Value(); 109 double maximumAgeDouble = maximumAgeNumber->Value();
110 if (std::isinf(maximumAgeDouble) && maximumAgeDouble > 0) { 110 if (std::isinf(maximumAgeDouble) && maximumAgeDouble > 0) {
111 // If the value is positive infinity, clear maximumAge. 111 // If the value is positive infinity, clear maximumAge.
112 options->clearMaximumAge(); 112 options->clearMaximumAge();
113 } else { 113 } else {
114 v8::Local<v8::Int32> maximumAgeInt32 = maximumAgeValue->ToInt32(); 114 v8::Local<v8::Uint32> maximumAgeUint32 = maximumAgeValue->ToUint32() ;
115 if (maximumAgeInt32.IsEmpty()) { 115 if (maximumAgeUint32.IsEmpty()) {
116 succeeded = false; 116 succeeded = false;
117 return nullptr; 117 return nullptr;
118 } 118 }
119 // Wrap to int32 and force non-negative to match behavior of window. setTimeout. 119 // Wrap to int32 and force non-negative to match behavior of window. setTimeout.
Michael van Ouwerkerk 2014/05/13 16:15:17 Update comment.
kihong 2014/05/14 03:44:25 Done.
120 options->setMaximumAge(max(0, maximumAgeInt32->Value())); 120 options->setMaximumAge(std::max<unsigned>(0, maximumAgeUint32->Value ()));
121 } 121 }
122 } 122 }
123 123
124 return options.release(); 124 return options.release();
125 } 125 }
126 126
127 void V8Geolocation::getCurrentPositionMethodCustom(const v8::FunctionCallbackInf o<v8::Value>& info) 127 void V8Geolocation::getCurrentPositionMethodCustom(const v8::FunctionCallbackInf o<v8::Value>& info)
128 { 128 {
129 bool succeeded = false; 129 bool succeeded = false;
130 130
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (!succeeded) 169 if (!succeeded)
170 return; 170 return;
171 ASSERT(positionOptions); 171 ASSERT(positionOptions);
172 172
173 Geolocation* geolocation = V8Geolocation::toNative(info.Holder()); 173 Geolocation* geolocation = V8Geolocation::toNative(info.Holder());
174 int watchId = geolocation->watchPosition(positionCallback.release(), positio nErrorCallback.release(), positionOptions.release()); 174 int watchId = geolocation->watchPosition(positionCallback.release(), positio nErrorCallback.release(), positionOptions.release());
175 v8SetReturnValue(info, watchId); 175 v8SetReturnValue(info, watchId);
176 } 176 }
177 177
178 } // namespace WebCore 178 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698