Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 | 88 |
| 89 // static | 89 // static |
| 90 std::unique_ptr<WebMessagePortChannelArray> | 90 std::unique_ptr<WebMessagePortChannelArray> |
| 91 MessagePort::toWebMessagePortChannelArray( | 91 MessagePort::toWebMessagePortChannelArray( |
| 92 std::unique_ptr<MessagePortChannelArray> channels) { | 92 std::unique_ptr<MessagePortChannelArray> channels) { |
| 93 std::unique_ptr<WebMessagePortChannelArray> webChannels; | 93 std::unique_ptr<WebMessagePortChannelArray> webChannels; |
| 94 if (channels && channels->size()) { | 94 if (channels && channels->size()) { |
| 95 webChannels = | 95 webChannels = |
| 96 WTF::wrapUnique(new WebMessagePortChannelArray(channels->size())); | 96 WTF::wrapUnique(new WebMessagePortChannelArray(channels->size())); |
| 97 for (size_t i = 0; i < channels->size(); ++i) | 97 for (size_t i = 0; i < channels->size(); ++i) |
| 98 (*webChannels)[i] = (*channels)[i].release(); | 98 (*webChannels)[i].reset((*channels)[i].release()); |
|
dcheng
2017/02/07 00:01:37
Nit: does webChannels[i] = std::move((*channels)[i
darin (slow to review)
2017/02/07 00:06:13
Done.
| |
| 99 } | 99 } |
| 100 return webChannels; | 100 return webChannels; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // static | 103 // static |
| 104 MessagePortArray* MessagePort::toMessagePortArray( | 104 MessagePortArray* MessagePort::toMessagePortArray( |
| 105 ExecutionContext* context, | 105 ExecutionContext* context, |
| 106 const WebMessagePortChannelArray& webChannels) { | 106 WebMessagePortChannelArray webChannels) { |
| 107 std::unique_ptr<MessagePortChannelArray> channels = | 107 std::unique_ptr<MessagePortChannelArray> channels = |
| 108 WTF::wrapUnique(new MessagePortChannelArray(webChannels.size())); | 108 WTF::wrapUnique(new MessagePortChannelArray(webChannels.size())); |
| 109 for (size_t i = 0; i < webChannels.size(); ++i) | 109 for (size_t i = 0; i < webChannels.size(); ++i) |
| 110 (*channels)[i] = WebMessagePortChannelUniquePtr(webChannels[i]); | 110 (*channels)[i] = std::move(webChannels[i]); |
| 111 return MessagePort::entanglePorts(*context, std::move(channels)); | 111 return MessagePort::entanglePorts(*context, std::move(channels)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 WebMessagePortChannelUniquePtr MessagePort::disentangle() { | 114 WebMessagePortChannelUniquePtr MessagePort::disentangle() { |
| 115 DCHECK(m_entangledChannel); | 115 DCHECK(m_entangledChannel); |
| 116 m_entangledChannel->setClient(nullptr); | 116 m_entangledChannel->setClient(nullptr); |
| 117 return std::move(m_entangledChannel); | 117 return std::move(m_entangledChannel); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Invoked to notify us that there are messages available for this port. | 120 // Invoked to notify us that there are messages available for this port. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 RefPtr<SerializedScriptValue>& message, | 168 RefPtr<SerializedScriptValue>& message, |
| 169 std::unique_ptr<MessagePortChannelArray>& channels) { | 169 std::unique_ptr<MessagePortChannelArray>& channels) { |
| 170 WebString messageString; | 170 WebString messageString; |
| 171 WebMessagePortChannelArray webChannels; | 171 WebMessagePortChannelArray webChannels; |
| 172 if (!webChannel.tryGetMessage(&messageString, webChannels)) | 172 if (!webChannel.tryGetMessage(&messageString, webChannels)) |
| 173 return false; | 173 return false; |
| 174 | 174 |
| 175 if (webChannels.size()) { | 175 if (webChannels.size()) { |
| 176 channels = WTF::wrapUnique(new MessagePortChannelArray(webChannels.size())); | 176 channels = WTF::wrapUnique(new MessagePortChannelArray(webChannels.size())); |
| 177 for (size_t i = 0; i < webChannels.size(); ++i) | 177 for (size_t i = 0; i < webChannels.size(); ++i) |
| 178 (*channels)[i] = WebMessagePortChannelUniquePtr(webChannels[i]); | 178 (*channels)[i] = std::move(webChannels[i]); |
| 179 } | 179 } |
| 180 message = SerializedScriptValue::create(messageString); | 180 message = SerializedScriptValue::create(messageString); |
| 181 return true; | 181 return true; |
| 182 } | 182 } |
| 183 | 183 |
| 184 bool MessagePort::tryGetMessage( | 184 bool MessagePort::tryGetMessage( |
| 185 RefPtr<SerializedScriptValue>& message, | 185 RefPtr<SerializedScriptValue>& message, |
| 186 std::unique_ptr<MessagePortChannelArray>& channels) { | 186 std::unique_ptr<MessagePortChannelArray>& channels) { |
| 187 if (!m_entangledChannel) | 187 if (!m_entangledChannel) |
| 188 return false; | 188 return false; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 } | 288 } |
| 289 return portArray; | 289 return portArray; |
| 290 } | 290 } |
| 291 | 291 |
| 292 DEFINE_TRACE(MessagePort) { | 292 DEFINE_TRACE(MessagePort) { |
| 293 ContextLifecycleObserver::trace(visitor); | 293 ContextLifecycleObserver::trace(visitor); |
| 294 EventTargetWithInlineData::trace(visitor); | 294 EventTargetWithInlineData::trace(visitor); |
| 295 } | 295 } |
| 296 | 296 |
| 297 } // namespace blink | 297 } // namespace blink |
| OLD | NEW |