OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 TextEncoder::~TextEncoder() {} | 53 TextEncoder::~TextEncoder() {} |
54 | 54 |
55 String TextEncoder::encoding() const { | 55 String TextEncoder::encoding() const { |
56 String name = String(encoding_.GetName()).DeprecatedLower(); | 56 String name = String(encoding_.GetName()).DeprecatedLower(); |
57 DCHECK_EQ(name, "utf-8"); | 57 DCHECK_EQ(name, "utf-8"); |
58 return name; | 58 return name; |
59 } | 59 } |
60 | 60 |
61 DOMUint8Array* TextEncoder::encode(const String& input) { | 61 NotShared<DOMUint8Array> TextEncoder::encode(const String& input) { |
62 CString result; | 62 CString result; |
63 if (input.Is8Bit()) | 63 if (input.Is8Bit()) |
64 result = codec_->Encode(input.Characters8(), input.length(), | 64 result = codec_->Encode(input.Characters8(), input.length(), |
65 WTF::kQuestionMarksForUnencodables); | 65 WTF::kQuestionMarksForUnencodables); |
66 else | 66 else |
67 result = codec_->Encode(input.Characters16(), input.length(), | 67 result = codec_->Encode(input.Characters16(), input.length(), |
68 WTF::kQuestionMarksForUnencodables); | 68 WTF::kQuestionMarksForUnencodables); |
69 | 69 |
70 const char* buffer = result.Data(); | 70 const char* buffer = result.Data(); |
71 const unsigned char* unsigned_buffer = | 71 const unsigned char* unsigned_buffer = |
72 reinterpret_cast<const unsigned char*>(buffer); | 72 reinterpret_cast<const unsigned char*>(buffer); |
73 | 73 |
74 return DOMUint8Array::Create(unsigned_buffer, result.length()); | 74 return NotShared<DOMUint8Array>( |
| 75 DOMUint8Array::Create(unsigned_buffer, result.length())); |
75 } | 76 } |
76 | 77 |
77 } // namespace blink | 78 } // namespace blink |
OLD | NEW |