Index: Source/modules/serviceworkers/StashedPortCollection.cpp |
diff --git a/Source/modules/serviceworkers/StashedPortCollection.cpp b/Source/modules/serviceworkers/StashedPortCollection.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..409df7e5b46e69f148d7d0c55ba5c90d11318e5f |
--- /dev/null |
+++ b/Source/modules/serviceworkers/StashedPortCollection.cpp |
@@ -0,0 +1,61 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "modules/serviceworkers/StashedPortCollection.h" |
+ |
+#include "bindings/core/v8/SerializedScriptValueFactory.h" |
+#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
+#include "modules/serviceworkers/StashedMessagePort.h" |
+#include "public/platform/WebString.h" |
+ |
+namespace blink { |
+ |
+PassRefPtrWillBeRawPtr<StashedPortCollection> StashedPortCollection::create(ExecutionContext* context) |
+{ |
+ return adoptRefWillBeNoop(new StashedPortCollection(context)); |
+} |
+ |
+StashedPortCollection::StashedPortCollection(ExecutionContext* context) |
+ : ContextLifecycleObserver(context) |
+{ |
+} |
+ |
+StashedPortCollection::~StashedPortCollection() |
+{ |
+} |
+ |
+PassRefPtrWillBeRawPtr<StashedMessagePort> StashedPortCollection::add(ScriptState* scriptState, const String& name, MessagePort* port) |
+{ |
+ OwnPtr<WebMessagePortChannel> webChannel = port->disentangle(); |
+ ServiceWorkerGlobalScopeClient::from(executionContext())->stashMessagePort(webChannel.get(), name); |
+ RefPtrWillBeRawPtr<StashedMessagePort> stashedPort = StashedMessagePort::create(*executionContext(), webChannel.release(), name); |
+ m_ports.append(stashedPort); |
+ return stashedPort; |
+} |
+ |
+void StashedPortCollection::addPorts(const StashedMessagePortArray& ports) |
+{ |
+ m_ports.appendVector(ports); |
+} |
+ |
+const AtomicString& StashedPortCollection::interfaceName() const |
+{ |
+ static AtomicString s; |
scheib
2015/05/06 21:44:31
Document why empty string.
From EventTarget:
// -
Marijn Kruisselbrink
2015/05/12 06:56:41
My mistake, shouldn't be empty string of course.
|
+ return s; |
+} |
+ |
+ExecutionContext* StashedPortCollection::executionContext() const |
+{ |
+ return ContextLifecycleObserver::executionContext(); |
+} |
+ |
+DEFINE_TRACE(StashedPortCollection) |
+{ |
+ EventTargetWithInlineData::trace(visitor); |
+ ContextLifecycleObserver::trace(visitor); |
+} |
+ |
+} // namespace blink |
+ |