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

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: Created 4 years 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: 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 d26008add8582a518c4962370abd62d3271ca54a..3c6f32d94701908ad733deada454d4d11d5f29c2 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
@@ -28,14 +28,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;
}
@@ -166,9 +170,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());
haraken 2016/12/23 14:26:10 Not related to this CL, getExecutionContext() retu
zhaobin 2016/12/30 05:05:00 Done.
+ 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();
}

Powered by Google App Engine
This is Rietveld 408576698