| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/push_messaging/PushMessageData.h" | 6 #include "modules/push_messaging/PushMessageData.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 { | 49 { |
| 50 m_data.append(data, bytesSize); | 50 m_data.append(data, bytesSize); |
| 51 } | 51 } |
| 52 | 52 |
| 53 PushMessageData::~PushMessageData() | 53 PushMessageData::~PushMessageData() |
| 54 { | 54 { |
| 55 } | 55 } |
| 56 | 56 |
| 57 PassRefPtr<DOMArrayBuffer> PushMessageData::arrayBuffer() const | 57 PassRefPtr<DOMArrayBuffer> PushMessageData::arrayBuffer() const |
| 58 { | 58 { |
| 59 return DOMArrayBuffer::create(m_data.data(), m_data.size()); | 59 // TODO(junov): crbug.com/536816 |
| 60 // Use createOrNull instead of deprecatedCreateOrCrash. Requires |
| 61 // defining behavior for when allocation fails. ECMAScript spec says |
| 62 // allocation failure should throw a RangeError exception, but the |
| 63 // spec for PushMessageData.arrayBuffer() does not state that |
| 64 // such exceptions should be re-thrown. So for now, we just crash. |
| 65 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::deprecatedCreateOrCrash(m_da
ta.data(), m_data.size()); |
| 66 return buffer.release(); |
| 60 } | 67 } |
| 61 | 68 |
| 62 Blob* PushMessageData::blob() const | 69 Blob* PushMessageData::blob() const |
| 63 { | 70 { |
| 64 OwnPtr<BlobData> blobData = BlobData::create(); | 71 OwnPtr<BlobData> blobData = BlobData::create(); |
| 65 blobData->appendBytes(m_data.data(), m_data.size()); | 72 blobData->appendBytes(m_data.data(), m_data.size()); |
| 66 | 73 |
| 67 // Note that the content type of the Blob object is deliberately not being | 74 // Note that the content type of the Blob object is deliberately not being |
| 68 // provided, following the specification. | 75 // provided, following the specification. |
| 69 | 76 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 91 String PushMessageData::text() const | 98 String PushMessageData::text() const |
| 92 { | 99 { |
| 93 return UTF8Encoding().decode(m_data.data(), m_data.size()); | 100 return UTF8Encoding().decode(m_data.data(), m_data.size()); |
| 94 } | 101 } |
| 95 | 102 |
| 96 DEFINE_TRACE(PushMessageData) | 103 DEFINE_TRACE(PushMessageData) |
| 97 { | 104 { |
| 98 } | 105 } |
| 99 | 106 |
| 100 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |