| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // All data that is passed through a WebSocket with type "Text" needs to be | 5 // All data that is passed through a WebSocket with type "Text" needs to be |
| 6 // validated as UTF8. Since this is done on the IO thread, it needs to be | 6 // validated as UTF8. Since this is done on the IO thread, it needs to be |
| 7 // reasonably fast. | 7 // reasonably fast. |
| 8 | 8 |
| 9 // We are only interested in the performance on valid UTF8. Invalid UTF8 will | 9 // We are only interested in the performance on valid UTF8. Invalid UTF8 will |
| 10 // result in a connection failure, so is unlikely to become a source of | 10 // result in a connection failure, so is unlikely to become a source of |
| 11 // performance issues. | 11 // performance issues. |
| 12 | 12 |
| 13 #include "base/i18n/streaming_utf8_validator.h" | 13 #include "base/i18n/streaming_utf8_validator.h" |
| 14 | 14 |
| 15 #include <stddef.h> |
| 16 |
| 15 #include <string> | 17 #include <string> |
| 16 | 18 |
| 17 #include "base/basictypes.h" | |
| 18 #include "base/bind.h" | 19 #include "base/bind.h" |
| 19 #include "base/callback.h" | 20 #include "base/callback.h" |
| 21 #include "base/macros.h" |
| 20 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 22 #include "base/test/perf_time_logger.h" | 24 #include "base/test/perf_time_logger.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 26 |
| 25 namespace base { | 27 namespace base { |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 // We want to test ranges of valid UTF-8 sequences. These ranges are inclusive. | 30 // We want to test ranges of valid UTF-8 sequences. These ranges are inclusive. |
| 29 // They are intended to be large enough that the validator needs to do | 31 // They are intended to be large enough that the validator needs to do |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 RunSomeTests("%s: bytes=4 ranged length=%d repeat=%d", | 231 RunSomeTests("%s: bytes=4 ranged length=%d repeat=%d", |
| 230 base::Bind(ConstructRangedTestString, | 232 base::Bind(ConstructRangedTestString, |
| 231 kFourByteSeqRangeStart, | 233 kFourByteSeqRangeStart, |
| 232 kFourByteSeqRangeEnd), | 234 kFourByteSeqRangeEnd), |
| 233 kTestFunctions, | 235 kTestFunctions, |
| 234 2); | 236 2); |
| 235 } | 237 } |
| 236 | 238 |
| 237 } // namespace | 239 } // namespace |
| 238 } // namespace base | 240 } // namespace base |
| OLD | NEW |