| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 10 matching lines...) Expand all Loading... |
| 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 #include "public/platform/WebData.h" | 31 #include "public/platform/WebMediaElementSource.h" |
| 32 | |
| 33 #include "platform/SharedBuffer.h" | |
| 34 | 32 |
| 35 namespace blink { | 33 namespace blink { |
| 36 | 34 |
| 37 void WebData::reset() | 35 WebMediaElementSource::WebMediaElementSource() |
| 38 { | |
| 39 m_private.reset(); | |
| 40 } | |
| 41 | |
| 42 void WebData::assign(const WebData& other) | |
| 43 { | |
| 44 m_private = other.m_private; | |
| 45 } | |
| 46 | |
| 47 void WebData::assign(const char* data, size_t size) | |
| 48 { | |
| 49 m_private = SharedBuffer::create(data, size); | |
| 50 } | |
| 51 | |
| 52 size_t WebData::size() const | |
| 53 { | |
| 54 if (m_private.isNull()) | |
| 55 return 0; | |
| 56 return m_private->size(); | |
| 57 } | |
| 58 | |
| 59 const char* WebData::data() const | |
| 60 { | |
| 61 if (m_private.isNull()) | |
| 62 return 0; | |
| 63 return m_private->data(); | |
| 64 } | |
| 65 | |
| 66 WebData::WebData(const PassRefPtr<SharedBuffer>& buffer) | |
| 67 : m_private(buffer) | |
| 68 { | 36 { |
| 69 } | 37 } |
| 70 | 38 |
| 71 WebData& WebData::operator=(const PassRefPtr<SharedBuffer>& buffer) | 39 WebMediaElementSource::WebMediaElementSource(const WebURL& url) |
| 40 : m_url(url) |
| 72 { | 41 { |
| 73 m_private = buffer; | |
| 74 return *this; | |
| 75 } | 42 } |
| 76 | 43 |
| 77 WebData::operator PassRefPtr<SharedBuffer>() const | 44 WebMediaElementSource::WebMediaElementSource(const WebMediaStream& mediaStream) |
| 45 : m_mediaStream(mediaStream) |
| 78 { | 46 { |
| 79 return PassRefPtr<SharedBuffer>(m_private.get()); | 47 } |
| 48 |
| 49 WebMediaElementSource::~WebMediaElementSource() |
| 50 { |
| 51 m_mediaStream.reset(); |
| 52 } |
| 53 |
| 54 bool WebMediaElementSource::isEmpty() const |
| 55 { |
| 56 return !isURL() && !isMediaProviderObject(); |
| 57 } |
| 58 |
| 59 bool WebMediaElementSource::isURL() const |
| 60 { |
| 61 return !m_url.isEmpty(); |
| 62 } |
| 63 |
| 64 WebURL WebMediaElementSource::getAsURL() const |
| 65 { |
| 66 return m_url; |
| 67 } |
| 68 |
| 69 bool WebMediaElementSource::isMediaProviderObject() const |
| 70 { |
| 71 return isMediaStream(); |
| 72 } |
| 73 |
| 74 bool WebMediaElementSource::isMediaStream() const |
| 75 { |
| 76 return !m_mediaStream.isNull(); |
| 77 } |
| 78 |
| 79 WebMediaStream WebMediaElementSource::getAsMediaStream() const |
| 80 { |
| 81 return m_mediaStream; |
| 80 } | 82 } |
| 81 | 83 |
| 82 } // namespace blink | 84 } // namespace blink |
| OLD | NEW |