OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "modules/serviceworkers/StashedPortCollection.h" |
| 7 |
| 8 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 9 #include "modules/EventTargetModules.h" |
| 10 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| 11 #include "modules/serviceworkers/StashedMessagePort.h" |
| 12 #include "public/platform/WebString.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 PassRefPtrWillBeRawPtr<StashedPortCollection> StashedPortCollection::create(Exec
utionContext* context) |
| 17 { |
| 18 return adoptRefWillBeNoop(new StashedPortCollection(context)); |
| 19 } |
| 20 |
| 21 StashedPortCollection::StashedPortCollection(ExecutionContext* context) |
| 22 : ContextLifecycleObserver(context) |
| 23 { |
| 24 } |
| 25 |
| 26 StashedPortCollection::~StashedPortCollection() |
| 27 { |
| 28 } |
| 29 |
| 30 void StashedPortCollection::addPorts(const StashedMessagePortArray& ports) |
| 31 { |
| 32 m_ports.appendVector(ports); |
| 33 } |
| 34 |
| 35 PassRefPtrWillBeRawPtr<StashedMessagePort> StashedPortCollection::add(ScriptStat
e* scriptState, const String& name, MessagePort* port) |
| 36 { |
| 37 OwnPtr<WebMessagePortChannel> webChannel = port->disentangle(); |
| 38 ServiceWorkerGlobalScopeClient::from(executionContext())->stashMessagePort(w
ebChannel.get(), name); |
| 39 RefPtrWillBeRawPtr<StashedMessagePort> stashedPort = StashedMessagePort::cre
ate(*executionContext(), webChannel.release(), name); |
| 40 m_ports.append(stashedPort); |
| 41 return stashedPort; |
| 42 } |
| 43 |
| 44 const AtomicString& StashedPortCollection::interfaceName() const |
| 45 { |
| 46 return EventTargetNames::StashedPortCollection; |
| 47 } |
| 48 |
| 49 ExecutionContext* StashedPortCollection::executionContext() const |
| 50 { |
| 51 return ContextLifecycleObserver::executionContext(); |
| 52 } |
| 53 |
| 54 DEFINE_TRACE(StashedPortCollection) |
| 55 { |
| 56 EventTargetWithInlineData::trace(visitor); |
| 57 ContextLifecycleObserver::trace(visitor); |
| 58 } |
| 59 |
| 60 } // namespace blink |
| 61 |
OLD | NEW |