Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2016 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 |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
| 17 * | 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebRTCVoidRequest_h | 31 #ifndef WebStringUTF8Adaptor_h |
| 32 #define WebRTCVoidRequest_h | 32 #define WebStringUTF8Adaptor_h |
| 33 | 33 |
| 34 #include "base/strings/string_piece.h" | |
| 34 #include "WebCommon.h" | 35 #include "WebCommon.h" |
| 35 #include "WebNonCopyable.h" | |
| 36 #include "WebPrivatePtr.h" | 36 #include "WebPrivatePtr.h" |
| 37 #include "WebString.h" | 37 |
| 38 namespace WTF { | |
| 39 class CStringBuffer; | |
| 40 } | |
| 38 | 41 |
| 39 namespace blink { | 42 namespace blink { |
| 40 | 43 |
| 41 class RTCVoidRequest; | 44 class WebString; |
| 42 | 45 |
| 43 class WebRTCVoidRequest { | 46 // This class lets you get UTF-8 data out of a String without mallocing a |
| 47 // separate buffer to hold the data if the String happens to be 8 bit and | |
| 48 // contain only ASCII characters. | |
| 49 // | |
| 50 // The string passed to the constructor must outlive this class since the | |
| 51 // returned StringPiece might point into it (which is the whole point). | |
| 52 class BLINK_COMMON_EXPORT WebStringUTF8Adaptor { | |
| 44 public: | 53 public: |
| 45 WebRTCVoidRequest() { } | 54 WebStringUTF8Adaptor(const WebString& string); |
| 46 WebRTCVoidRequest(const WebRTCVoidRequest& other) { assign(other); } | 55 ~WebStringUTF8Adaptor(); |
| 47 ~WebRTCVoidRequest() { reset(); } | |
| 48 | 56 |
| 49 WebRTCVoidRequest& operator=(const WebRTCVoidRequest& other) | 57 base::StringPiece asStringPiece() const { return m_stringPiece; } |
| 50 { | |
| 51 assign(other); | |
| 52 return *this; | |
| 53 } | |
| 54 | |
| 55 BLINK_PLATFORM_EXPORT void assign(const WebRTCVoidRequest&); | |
| 56 | |
| 57 BLINK_PLATFORM_EXPORT void reset(); | |
| 58 bool isNull() const { return m_private.isNull(); } | |
| 59 | |
| 60 BLINK_PLATFORM_EXPORT void requestSucceeded() const; | |
| 61 BLINK_PLATFORM_EXPORT void requestFailed(const WebString& error) const; | |
| 62 | |
| 63 #if INSIDE_BLINK | |
| 64 BLINK_PLATFORM_EXPORT WebRTCVoidRequest(RTCVoidRequest*); | |
| 65 #endif | |
| 66 | 58 |
| 67 private: | 59 private: |
| 68 WebPrivatePtr<RTCVoidRequest> m_private; | 60 base::StringPiece m_stringPiece; |
| 61 | |
| 62 // Holds the UTF-8 buffer backing the string piece if conversion was necessa ry. | |
| 63 WebPrivatePtr<WTF::CStringBuffer> m_utf8Buffer; | |
|
esprehn
2016/01/13 02:02:31
CString ?
| |
| 69 }; | 64 }; |
| 70 | 65 |
| 71 } // namespace blink | 66 } // namespace blink |
| 72 | 67 |
| 73 #endif // WebRTCVoidRequest_h | 68 #endif |
| OLD | NEW |