Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/WebKit/Source/modules/encoding/TextEncoder.cpp

Issue 2707243006: [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: add some layout tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(m_encoding.name()).lower(); 56 String name = String(m_encoding.name()).lower();
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 = m_codec->encode(input.characters8(), input.length(), 64 result = m_codec->encode(input.characters8(), input.length(),
65 WTF::QuestionMarksForUnencodables); 65 WTF::QuestionMarksForUnencodables);
66 else 66 else
67 result = m_codec->encode(input.characters16(), input.length(), 67 result = m_codec->encode(input.characters16(), input.length(),
68 WTF::QuestionMarksForUnencodables); 68 WTF::QuestionMarksForUnencodables);
69 69
70 const char* buffer = result.data(); 70 const char* buffer = result.data();
71 const unsigned char* unsignedBuffer = 71 const unsigned char* unsignedBuffer =
72 reinterpret_cast<const unsigned char*>(buffer); 72 reinterpret_cast<const unsigned char*>(buffer);
73 73
74 return DOMUint8Array::create(unsignedBuffer, result.length()); 74 return NotShared<DOMUint8Array>(
75 DOMUint8Array::create(unsignedBuffer, result.length()));
75 } 76 }
76 77
77 } // namespace blink 78 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698