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

Unified Diff: third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp

Issue 2602523002: [Presentation API] Resolve PresentationRequest::reconnect() with existing presentation connection i… (Closed)
Patch Set: remove getExecutionContext() null check in PresentationRequest::reconnect() Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/modules/presentation/PresentationController.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
index b846410eb5486a690dd33e426bf2cc23a1d54927..afac635807e03600607faa8eb24c6a6410a4a636 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
@@ -15,6 +15,7 @@
#include "core/frame/UseCounter.h"
#include "core/loader/MixedContentChecker.h"
#include "modules/EventTargetModules.h"
+#include "modules/presentation/ExistingPresentationConnectionCallbacks.h"
#include "modules/presentation/PresentationAvailability.h"
#include "modules/presentation/PresentationAvailabilityCallbacks.h"
#include "modules/presentation/PresentationConnection.h"
@@ -28,14 +29,18 @@ namespace blink {
namespace {
// TODO(mlamouri): refactor in one common place.
-WebPresentationClient* presentationClient(ExecutionContext* executionContext) {
+PresentationController* presentationController(
+ ExecutionContext* executionContext) {
DCHECK(executionContext);
Document* document = toDocument(executionContext);
if (!document->frame())
return nullptr;
- PresentationController* controller =
- PresentationController::from(*document->frame());
+ return PresentationController::from(*document->frame());
+}
+
+WebPresentationClient* presentationClient(ExecutionContext* executionContext) {
+ PresentationController* controller = presentationController(executionContext);
return controller ? controller->client() : nullptr;
}
@@ -163,9 +168,23 @@ ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState,
// TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest.
WebVector<WebURL> presentationUrls(static_cast<size_t>(1U));
presentationUrls[0] = m_url;
- client->joinSession(
- presentationUrls, id,
- WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this));
+
+ PresentationController* controller =
+ presentationController(getExecutionContext());
+ DCHECK(controller);
+
+ PresentationConnection* existingConnection =
+ controller->findExistingConnection(presentationUrls, id);
+ if (existingConnection) {
+ client->joinSession(
+ presentationUrls, id,
+ WTF::makeUnique<ExistingPresentationConnectionCallbacks>(
+ resolver, existingConnection));
+ } else {
+ client->joinSession(
+ presentationUrls, id,
+ WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this));
+ }
return resolver->promise();
}
« no previous file with comments | « third_party/WebKit/Source/modules/presentation/PresentationController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698