Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Unified Diff: Source/modules/serviceworkers/StashedPortCollection.cpp

Issue 1008533005: Initial implementation of stashed message ports, blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add comment to ServiceWorkerGlobalScope.idl Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6e07294789bc7ab0413c687c77f344b65bce7534
--- /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/EventTargetModules.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()
+{
+}
+
+void StashedPortCollection::addPorts(const StashedMessagePortArray& ports)
+{
+ m_ports.appendVector(ports);
+}
+
+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;
+}
+
+const AtomicString& StashedPortCollection::interfaceName() const
+{
+ return EventTargetNames::StashedPortCollection;
+}
+
+ExecutionContext* StashedPortCollection::executionContext() const
+{
+ return ContextLifecycleObserver::executionContext();
+}
+
+DEFINE_TRACE(StashedPortCollection)
+{
+ EventTargetWithInlineData::trace(visitor);
+ ContextLifecycleObserver::trace(visitor);
+}
+
+} // namespace blink
+

Powered by Google App Engine
This is Rietveld 408576698