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

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

Issue 1024903003: [Presentation API] Plumbing of |onstatechange| from the Mojo service to the public/platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 eec933b874dba7d3ebdf510d6dc3833d3e3a74e5..e816e6059d9ca30caa2808ca807a2dd7c5224f8a 100644
--- a/content/renderer/presentation/presentation_dispatcher.cc
+++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -33,6 +33,19 @@ blink::WebPresentationError::ErrorType GetWebPresentationErrorTypeFromMojo(
}
}
+blink::WebPresentationSessionClient::SessionState
+ GetWebPresentationSessionStateFromMojo(
+ presentation::PresentationSessionState mojoSessionState) {
+ switch (mojoSessionState) {
+ case presentation::PRESENTATION_SESSION_STATE_CONNECTED:
+ return blink::WebPresentationSessionClient::SessionStateConnected;
+ case presentation::PRESENTATION_SESSION_STATE_DISCONNECTED:
+ return blink::WebPresentationSessionClient::SessionStateDisconnected;
+ default:
Peter Beverloo 2015/03/20 19:13:39 Are there more than two options in the generated e
whywhat 2015/03/24 19:20:57 Done.
+ return blink::WebPresentationSessionClient::SessionStateUnknown;
+ }
+}
+
GURL GetPresentationURLFromFrame(content::RenderFrame* frame) {
DCHECK(frame);
@@ -161,11 +174,8 @@ void PresentationDispatcher::OnDefaultSessionStarted(
base::Unretained(this)));
DCHECK(!session_info.is_null());
- PresentationSessionDispatcher* session_dispatcher =
- new PresentationSessionDispatcher(session_info.Pass());
- presentation_session_dispatchers_.push_back(session_dispatcher);
controller_->didStartDefaultSession(
- new PresentationSessionClient(session_dispatcher));
+ new PresentationSessionClient(session_info.Pass()));
}
void PresentationDispatcher::OnSessionCreated(
@@ -182,10 +192,16 @@ void PresentationDispatcher::OnSessionCreated(
}
DCHECK(!session_info.is_null());
- PresentationSessionDispatcher* session_dispatcher =
- new PresentationSessionDispatcher(session_info.Pass());
- presentation_session_dispatchers_.push_back(session_dispatcher);
- callback->onSuccess(new PresentationSessionClient(session_dispatcher));
+ callback->onSuccess(new PresentationSessionClient(session_info.Pass()));
+}
+
+void PresentationDispatcher::OnSessionStateChange(
+ presentation::PresentationSessionInfoPtr session_info,
+ presentation::PresentationSessionState session_state) {
+ DCHECK(!session_info.is_null());
+ controller_->didChangeSessionState(
imcheng 2015/03/20 23:01:46 Does controller_ hold references to multiple Prese
whywhat 2015/03/24 19:20:58 Presentation has a set of PresentationSession obje
+ new PresentationSessionClient(session_info.Pass()),
Peter Beverloo 2015/03/20 19:13:39 It would be nice if you could document in the WebP
whywhat 2015/03/24 19:20:57 It would be nice to read this comment before submi
+ GetWebPresentationSessionStateFromMojo(session_state));
}
void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
@@ -197,6 +213,9 @@ void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
presentation_service_->ListenForDefaultSessionStart(base::Bind(
&PresentationDispatcher::OnDefaultSessionStarted,
base::Unretained(this)));
+ presentation_service_->ListenForSessionStateChange(base::Bind(
+ &PresentationDispatcher::OnSessionStateChange,
imcheng 2015/03/20 23:01:46 How does PresentationServiceImpl know which sessio
whywhat 2015/03/24 19:20:58 PresentationServiceImpl should call the callback f
+ base::Unretained(this)));
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698