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

Unified Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 935083002: [PresentationAPI] Implementing start/joinSession from WebPresentationClient to PresentationService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: is_null() checks for StructPtr's instead of get() Created 5 years, 10 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: content/renderer/presentation/presentation_dispatcher.cc
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc
index 04b44eca6fe231e3e98c363f1f4b64339ad4ec8f..b1e4fd4bdddf19cbb6aeb772ae67dac395237503 100644
--- a/content/renderer/presentation/presentation_dispatcher.cc
+++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -8,6 +8,7 @@
#include "content/public/common/service_registry.h"
#include "content/public/renderer/render_frame.h"
#include "third_party/WebKit/public/platform/modules/presentation/WebPresentationController.h"
+#include "third_party/WebKit/public/platform/modules/presentation/WebPresentationError.h"
namespace content {
@@ -44,6 +45,32 @@ void PresentationDispatcher::updateAvailableChangeWatched(bool watched) {
}
}
+void PresentationDispatcher::startSession(
+ const blink::WebString& presentationUrl,
+ const blink::WebString& presentationId,
+ blink::WebPresentationSessionClientCallbacks* callback) {
+ ConnectToPresentationServiceIfNeeded();
+ presentation_service_->StartSession(
+ presentationUrl.utf8(),
+ presentationId.utf8(),
+ base::Bind(&PresentationDispatcher::OnSessionCreated,
+ base::Unretained(this),
+ base::Unretained(callback)));
mlamouri (slow - plz ping) 2015/02/23 14:07:39 base::Owned(callback)
whywhat 2015/02/25 14:12:41 Done. Actually atm the callback owns/deletes itsel
+}
+
+void PresentationDispatcher::joinSession(
+ const blink::WebString& presentationUrl,
+ const blink::WebString& presentationId,
+ blink::WebPresentationSessionClientCallbacks* callback) {
+ ConnectToPresentationServiceIfNeeded();
+ presentation_service_->JoinSession(
+ presentationUrl.utf8(),
+ presentationId.utf8(),
+ base::Bind(&PresentationDispatcher::OnSessionCreated,
+ base::Unretained(this),
+ base::Unretained(callback)));
mlamouri (slow - plz ping) 2015/02/23 14:07:39 ditto
whywhat 2015/02/25 14:12:41 Done.
+}
+
void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) {
if (!controller_)
return;
@@ -54,6 +81,27 @@ void PresentationDispatcher::OnScreenAvailabilityChanged(bool available) {
controller_->didChangeAvailability(available);
}
+void PresentationDispatcher::OnSessionCreated(
+ blink::WebPresentationSessionClientCallbacks* callback,
+ presentation::PresentationSessionInfoPtr session_info,
+ presentation::PresentationErrorPtr error) {
+ if (!callback)
+ return;
+ if (!error.is_null()) {
+ DCHECK(session_info.is_null());
+ callback->onError(new blink::WebPresentationError(
+ error->errorCode,
mlamouri (slow - plz ping) 2015/02/23 14:07:39 You will need a switch to go from PresentationServ
whywhat 2015/02/25 14:12:41 Done.
+ blink::WebString::fromUTF8(error->message)));
+ return;
+ }
+
+ DCHECK(!session_info.is_null());
+ PresentationSessionDispatcher* session_dispatcher =
+ new PresentationSessionDispatcher(session_info.Pass());
+ presentation_sessions_.push_back(session_dispatcher);
+ callback->onSuccess(session_dispatcher);
mlamouri (slow - plz ping) 2015/02/23 14:07:39 PresentationDispatcher owns the callback. Please d
whywhat 2015/02/25 14:12:41 As I understand, it will be deleted automatically
+}
+
void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
if (presentation_service_.get())
return;

Powered by Google App Engine
This is Rietveld 408576698