| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef ValueConversions_h | 5 #ifndef ValueConversions_h |
| 6 #define ValueConversions_h | 6 #define ValueConversions_h |
| 7 | 7 |
| 8 #include "platform/inspector_protocol/ErrorSupport.h" | 8 #include "platform/inspector_protocol/ErrorSupport.h" |
| 9 #include "platform/inspector_protocol/Platform.h" | 9 #include "platform/inspector_protocol/Platform.h" |
| 10 #include "platform/inspector_protocol/String16.h" | 10 #include "platform/inspector_protocol/String16.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 errors->addError("boolean value expected"); | 57 errors->addError("boolean value expected"); |
| 58 return result; | 58 return result; |
| 59 } | 59 } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 template<> | 62 template<> |
| 63 struct FromValue<int> { | 63 struct FromValue<int> { |
| 64 static int parse(protocol::Value* value, ErrorSupport* errors) | 64 static int parse(protocol::Value* value, ErrorSupport* errors) |
| 65 { | 65 { |
| 66 int result = 0; | 66 int result = 0; |
| 67 bool success = value ? value->asNumber(&result) : false; | 67 bool success = value ? value->asInteger(&result) : false; |
| 68 if (!success) | 68 if (!success) |
| 69 errors->addError("integer value expected"); | 69 errors->addError("integer value expected"); |
| 70 return result; | 70 return result; |
| 71 } | 71 } |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 template<> | 74 template<> |
| 75 struct FromValue<double> { | 75 struct FromValue<double> { |
| 76 static double parse(protocol::Value* value, ErrorSupport* errors) | 76 static double parse(protocol::Value* value, ErrorSupport* errors) |
| 77 { | 77 { |
| 78 double result = 0; | 78 double result = 0; |
| 79 bool success = value ? value->asNumber(&result) : false; | 79 bool success = value ? value->asDouble(&result) : false; |
| 80 if (!success) | 80 if (!success) |
| 81 errors->addError("double value expected"); | 81 errors->addError("double value expected"); |
| 82 return result; | 82 return result; |
| 83 } | 83 } |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 template<> | 86 template<> |
| 87 struct FromValue<String> { | 87 struct FromValue<String> { |
| 88 static String parse(protocol::Value* value, ErrorSupport* errors) | 88 static String parse(protocol::Value* value, ErrorSupport* errors) |
| 89 { | 89 { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 static std::unique_ptr<protocol::Array<T>> parse(protocol::Value* value, Err
orSupport* errors) | 149 static std::unique_ptr<protocol::Array<T>> parse(protocol::Value* value, Err
orSupport* errors) |
| 150 { | 150 { |
| 151 return protocol::Array<T>::parse(value, errors); | 151 return protocol::Array<T>::parse(value, errors); |
| 152 } | 152 } |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 } // namespace platform | 155 } // namespace platform |
| 156 } // namespace blink | 156 } // namespace blink |
| 157 | 157 |
| 158 #endif // !defined(ValueConversions_h) | 158 #endif // !defined(ValueConversions_h) |
| OLD | NEW |