| OLD | NEW |
| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void didFinishLoading() override; | 73 void didFinishLoading() override; |
| 74 void didFail(FileError::ErrorCode) override; | 74 void didFail(FileError::ErrorCode) override; |
| 75 | 75 |
| 76 DEFINE_INLINE_TRACE() | 76 DEFINE_INLINE_TRACE() |
| 77 { | 77 { |
| 78 visitor->trace(m_channel); | 78 visitor->trace(m_channel); |
| 79 } | 79 } |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 Member<DocumentWebSocketChannel> m_channel; | 82 Member<DocumentWebSocketChannel> m_channel; |
| 83 FileReaderLoader m_loader; | 83 std::unique_ptr<FileReaderLoader> m_loader; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 class DocumentWebSocketChannel::Message : public GarbageCollectedFinalized<Docum
entWebSocketChannel::Message> { | 86 class DocumentWebSocketChannel::Message : public GarbageCollectedFinalized<Docum
entWebSocketChannel::Message> { |
| 87 public: | 87 public: |
| 88 explicit Message(const CString&); | 88 explicit Message(const CString&); |
| 89 explicit Message(PassRefPtr<BlobDataHandle>); | 89 explicit Message(PassRefPtr<BlobDataHandle>); |
| 90 explicit Message(DOMArrayBuffer*); | 90 explicit Message(DOMArrayBuffer*); |
| 91 // For WorkerWebSocketChannel | 91 // For WorkerWebSocketChannel |
| 92 explicit Message(std::unique_ptr<Vector<char>>, MessageType); | 92 explicit Message(std::unique_ptr<Vector<char>>, MessageType); |
| 93 // Close message | 93 // Close message |
| 94 Message(unsigned short code, const String& reason); | 94 Message(unsigned short code, const String& reason); |
| 95 | 95 |
| 96 DEFINE_INLINE_TRACE() | 96 DEFINE_INLINE_TRACE() |
| 97 { | 97 { |
| 98 visitor->trace(arrayBuffer); | 98 visitor->trace(arrayBuffer); |
| 99 } | 99 } |
| 100 | 100 |
| 101 MessageType type; | 101 MessageType type; |
| 102 | 102 |
| 103 CString text; | 103 CString text; |
| 104 RefPtr<BlobDataHandle> blobDataHandle; | 104 RefPtr<BlobDataHandle> blobDataHandle; |
| 105 Member<DOMArrayBuffer> arrayBuffer; | 105 Member<DOMArrayBuffer> arrayBuffer; |
| 106 std::unique_ptr<Vector<char>> vectorData; | 106 std::unique_ptr<Vector<char>> vectorData; |
| 107 unsigned short code; | 107 unsigned short code; |
| 108 String reason; | 108 String reason; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 DocumentWebSocketChannel::BlobLoader::BlobLoader(PassRefPtr<BlobDataHandle> blob
DataHandle, DocumentWebSocketChannel* channel) | 111 DocumentWebSocketChannel::BlobLoader::BlobLoader(PassRefPtr<BlobDataHandle> blob
DataHandle, DocumentWebSocketChannel* channel) |
| 112 : m_channel(channel) | 112 : m_channel(channel) |
| 113 , m_loader(FileReaderLoader::ReadAsArrayBuffer, this) | 113 , m_loader(FileReaderLoader::create(FileReaderLoader::ReadAsArrayBuffer, thi
s)) |
| 114 { | 114 { |
| 115 m_loader.start(channel->getExecutionContext(), blobDataHandle); | 115 m_loader->start(channel->getExecutionContext(), blobDataHandle); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void DocumentWebSocketChannel::BlobLoader::cancel() | 118 void DocumentWebSocketChannel::BlobLoader::cancel() |
| 119 { | 119 { |
| 120 m_loader.cancel(); | 120 m_loader->cancel(); |
| 121 // didFail will be called immediately. | 121 // didFail will be called immediately. |
| 122 // |this| is deleted here. | 122 // |this| is deleted here. |
| 123 } | 123 } |
| 124 | 124 |
| 125 void DocumentWebSocketChannel::BlobLoader::didFinishLoading() | 125 void DocumentWebSocketChannel::BlobLoader::didFinishLoading() |
| 126 { | 126 { |
| 127 m_channel->didFinishLoadingBlob(m_loader.arrayBufferResult()); | 127 m_channel->didFinishLoadingBlob(m_loader->arrayBufferResult()); |
| 128 // |this| is deleted here. | 128 // |this| is deleted here. |
| 129 } | 129 } |
| 130 | 130 |
| 131 void DocumentWebSocketChannel::BlobLoader::didFail(FileError::ErrorCode errorCod
e) | 131 void DocumentWebSocketChannel::BlobLoader::didFail(FileError::ErrorCode errorCod
e) |
| 132 { | 132 { |
| 133 m_channel->didFailLoadingBlob(errorCode); | 133 m_channel->didFailLoadingBlob(errorCode); |
| 134 // |this| is deleted here. | 134 // |this| is deleted here. |
| 135 } | 135 } |
| 136 | 136 |
| 137 DocumentWebSocketChannel::DocumentWebSocketChannel(Document* document, WebSocket
ChannelClient* client, std::unique_ptr<SourceLocation> location, WebSocketHandle
*handle) | 137 DocumentWebSocketChannel::DocumentWebSocketChannel(Document* document, WebSocket
ChannelClient* client, std::unique_ptr<SourceLocation> location, WebSocketHandle
*handle) |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 DEFINE_TRACE(DocumentWebSocketChannel) | 579 DEFINE_TRACE(DocumentWebSocketChannel) |
| 580 { | 580 { |
| 581 visitor->trace(m_blobLoader); | 581 visitor->trace(m_blobLoader); |
| 582 visitor->trace(m_messages); | 582 visitor->trace(m_messages); |
| 583 visitor->trace(m_client); | 583 visitor->trace(m_client); |
| 584 WebSocketChannel::trace(visitor); | 584 WebSocketChannel::trace(visitor); |
| 585 ContextLifecycleObserver::trace(visitor); | 585 ContextLifecycleObserver::trace(visitor); |
| 586 } | 586 } |
| 587 | 587 |
| 588 } // namespace blink | 588 } // namespace blink |
| OLD | NEW |