| Index: third_party/WebKit/Source/platform/exported/WebStringUTF8Adaptor.cpp
|
| diff --git a/third_party/WebKit/public/platform/WebMIDIAccessor.h b/third_party/WebKit/Source/platform/exported/WebStringUTF8Adaptor.cpp
|
| similarity index 61%
|
| copy from third_party/WebKit/public/platform/WebMIDIAccessor.h
|
| copy to third_party/WebKit/Source/platform/exported/WebStringUTF8Adaptor.cpp
|
| index a31cfda7c842b869a9ed1767cbf6ceff4a3660c2..6383f71e76621d912b270b96cdc2a87207268221 100644
|
| --- a/third_party/WebKit/public/platform/WebMIDIAccessor.h
|
| +++ b/third_party/WebKit/Source/platform/exported/WebStringUTF8Adaptor.cpp
|
| @@ -1,5 +1,5 @@
|
| /*
|
| - * Copyright (C) 2013 Google Inc. All rights reserved.
|
| + * Copyright (C) 2016 Google Inc. All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions are
|
| @@ -28,25 +28,36 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#ifndef WebMIDIAccessor_h
|
| -#define WebMIDIAccessor_h
|
| +#include "public/platform/WebStringUTF8Adaptor.h"
|
|
|
| -#include "WebString.h"
|
| +#include "public/platform/WebString.h"
|
| +#include "wtf/text/CString.h"
|
| +#include "wtf/text/WTFString.h"
|
|
|
| namespace blink {
|
|
|
| -class WebMIDIAccessor {
|
| -public:
|
| - virtual ~WebMIDIAccessor() { }
|
| +WebStringUTF8Adaptor::WebStringUTF8Adaptor(const WebString& string)
|
| +{
|
| + if (string.isEmpty())
|
| + return;
|
| + // 8-bit WTF::Strings are encoded in Latin-1. If |relative| is entirely
|
| + // ASCII, we luck out and can avoid mallocing a new buffer to hold the
|
| + // UTF-8 data because UTF-8 and Latin-1 use the same code units for ASCII
|
| + // code points.
|
| + const WTF::String& wtfString = string;
|
| + if (wtfString.is8Bit() && wtfString.containsOnlyASCII()) {
|
| + m_stringPiece = base::StringPiece(
|
| + reinterpret_cast<const char*>(wtfString.characters8()),
|
| + wtfString.length());
|
| + } else {
|
| + m_utf8Buffer = wtfString.utf8().buffer();
|
| + m_stringPiece = base::StringPiece(m_utf8Buffer->data(), m_utf8Buffer->length());
|
| + }
|
| +}
|
|
|
| - virtual void startSession() { }
|
| - virtual void open(unsigned portIndex) { }
|
| - // |timeStamp| is measured in milliseconds as Web MIDI spec defines.
|
| - virtual void sendMIDIData(unsigned portIndex, const unsigned char* data, size_t length, double timeStamp) { }
|
| - virtual void clear(unsigned portIndex) { }
|
| - virtual void close(unsigned portIndex) { }
|
| -};
|
| +WebStringUTF8Adaptor::~WebStringUTF8Adaptor()
|
| +{
|
| + m_utf8Buffer.reset();
|
| +}
|
|
|
| } // namespace blink
|
| -
|
| -#endif // WebMIDIAccessor_h
|
|
|