| 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 <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/bind.h" | 18 #include "base/bind.h" |
| 19 #include "base/callback.h" | 19 #include "base/callback.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/test/perf_time_logger.h" | 22 #include "base/test/perf_time_logger.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/googletest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // We want to test ranges of valid UTF-8 sequences. These ranges are inclusive. | 28 // 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 | 29 // They are intended to be large enough that the validator needs to do |
| 30 // meaningful work while being in some sense "realistic" (eg. control characters | 30 // meaningful work while being in some sense "realistic" (eg. control characters |
| 31 // are not included). | 31 // are not included). |
| 32 const char kOneByteSeqRangeStart[] = " "; // U+0020 | 32 const char kOneByteSeqRangeStart[] = " "; // U+0020 |
| 33 const char kOneByteSeqRangeEnd[] = "~"; // U+007E | 33 const char kOneByteSeqRangeEnd[] = "~"; // U+007E |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 RunSomeTests("%s: bytes=4 ranged length=%d repeat=%d", | 229 RunSomeTests("%s: bytes=4 ranged length=%d repeat=%d", |
| 230 base::Bind(ConstructRangedTestString, | 230 base::Bind(ConstructRangedTestString, |
| 231 kFourByteSeqRangeStart, | 231 kFourByteSeqRangeStart, |
| 232 kFourByteSeqRangeEnd), | 232 kFourByteSeqRangeEnd), |
| 233 kTestFunctions, | 233 kTestFunctions, |
| 234 2); | 234 2); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace | 237 } // namespace |
| 238 } // namespace base | 238 } // namespace base |
| OLD | NEW |