OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.components.safejson; | 5 package org.chromium.components.safejson; |
6 | 6 |
7 import android.util.JsonReader; | 7 import android.util.JsonReader; |
8 import android.util.JsonToken; | 8 import android.util.JsonToken; |
9 import android.util.JsonWriter; | 9 import android.util.JsonWriter; |
10 import android.util.MalformedJsonException; | 10 import android.util.MalformedJsonException; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 nativeOnError(nativePtr, e.getMessage()); | 120 nativeOnError(nativePtr, e.getMessage()); |
121 return; | 121 return; |
122 } | 122 } |
123 nativeOnSuccess(nativePtr, result); | 123 nativeOnSuccess(nativePtr, result); |
124 } | 124 } |
125 | 125 |
126 /** | 126 /** |
127 * Helper class to check nesting depth of JSON expressions. | 127 * Helper class to check nesting depth of JSON expressions. |
128 */ | 128 */ |
129 private static class StackChecker { | 129 private static class StackChecker { |
130 private int mStackDepth = 0; | 130 private int mStackDepth; |
131 | 131 |
132 public void increaseAndCheck() { | 132 public void increaseAndCheck() { |
133 if (++mStackDepth >= MAX_NESTING_DEPTH) { | 133 if (++mStackDepth >= MAX_NESTING_DEPTH) { |
134 throw new IllegalStateException("Too much nesting"); | 134 throw new IllegalStateException("Too much nesting"); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 public void decrease() { | 138 public void decrease() { |
139 mStackDepth--; | 139 mStackDepth--; |
140 } | 140 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 private static boolean isUnicodeCharacter(int codePoint) { | 188 private static boolean isUnicodeCharacter(int codePoint) { |
189 // See the native method base::IsValidCharacter(). | 189 // See the native method base::IsValidCharacter(). |
190 return codePoint < 0xD800 || (codePoint >= 0xE000 && codePoint < 0xFDD0) | 190 return codePoint < 0xD800 || (codePoint >= 0xE000 && codePoint < 0xFDD0) |
191 || (codePoint > 0xFDEF && codePoint <= 0x10FFFF && (codePoint &
0xFFFE) != 0xFFFE); | 191 || (codePoint > 0xFDEF && codePoint <= 0x10FFFF && (codePoint &
0xFFFE) != 0xFFFE); |
192 } | 192 } |
193 | 193 |
194 private static native void nativeOnSuccess(long id, String json); | 194 private static native void nativeOnSuccess(long id, String json); |
195 | 195 |
196 private static native void nativeOnError(long id, String error); | 196 private static native void nativeOnError(long id, String error); |
197 } | 197 } |
OLD | NEW |