| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/presentation/presentation_service_impl.h" | 5 #include "content/browser/presentation/presentation_service_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/browser/presentation/presentation_type_converters.h" | 10 #include "content/browser/presentation/presentation_type_converters.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 void PresentationServiceImpl::ListenForDefaultSessionStart( | 227 void PresentationServiceImpl::ListenForDefaultSessionStart( |
| 228 const DefaultSessionMojoCallback& callback) { | 228 const DefaultSessionMojoCallback& callback) { |
| 229 if (!default_session_start_context_.get()) | 229 if (!default_session_start_context_.get()) |
| 230 default_session_start_context_.reset(new DefaultSessionStartContext); | 230 default_session_start_context_.reset(new DefaultSessionStartContext); |
| 231 default_session_start_context_->AddCallback(callback); | 231 default_session_start_context_->AddCallback(callback); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void PresentationServiceImpl::StartSession( | 234 void PresentationServiceImpl::StartSession( |
| 235 const mojo::String& presentation_url, | 235 const mojo::String& presentation_url, |
| 236 const mojo::String& presentation_id, | |
| 237 const NewSessionMojoCallback& callback) { | 236 const NewSessionMojoCallback& callback) { |
| 238 DVLOG(2) << "StartSession"; | 237 DVLOG(2) << "StartSession"; |
| 239 if (!delegate_) { | 238 if (!delegate_) { |
| 240 InvokeNewSessionMojoCallbackWithError(callback); | 239 InvokeNewSessionMojoCallbackWithError(callback); |
| 241 return; | 240 return; |
| 242 } | 241 } |
| 243 | 242 |
| 244 // There is a StartSession request in progress. To avoid queueing up | 243 // There is a StartSession request in progress. To avoid queueing up |
| 245 // requests, the incoming request is rejected. | 244 // requests, the incoming request is rejected. |
| 246 if (start_session_request_id_ != kInvalidRequestSessionId) { | 245 if (start_session_request_id_ != kInvalidRequestSessionId) { |
| 247 InvokeNewSessionMojoCallbackWithError(callback); | 246 InvokeNewSessionMojoCallbackWithError(callback); |
| 248 return; | 247 return; |
| 249 } | 248 } |
| 250 | 249 |
| 251 start_session_request_id_ = GetNextRequestSessionId(); | 250 start_session_request_id_ = GetNextRequestSessionId(); |
| 252 pending_start_session_cb_.reset(new NewSessionMojoCallbackWrapper(callback)); | 251 pending_start_session_cb_.reset(new NewSessionMojoCallbackWrapper(callback)); |
| 253 delegate_->StartSession( | 252 delegate_->StartSession( |
| 254 render_process_id_, render_frame_id_, presentation_url, presentation_id, | 253 render_process_id_, render_frame_id_, presentation_url, |
| 255 base::Bind(&PresentationServiceImpl::OnStartSessionSucceeded, | 254 base::Bind(&PresentationServiceImpl::OnStartSessionSucceeded, |
| 256 weak_factory_.GetWeakPtr(), start_session_request_id_), | 255 weak_factory_.GetWeakPtr(), start_session_request_id_), |
| 257 base::Bind(&PresentationServiceImpl::OnStartSessionError, | 256 base::Bind(&PresentationServiceImpl::OnStartSessionError, |
| 258 weak_factory_.GetWeakPtr(), start_session_request_id_)); | 257 weak_factory_.GetWeakPtr(), start_session_request_id_)); |
| 259 } | 258 } |
| 260 | 259 |
| 261 void PresentationServiceImpl::JoinSession( | 260 void PresentationServiceImpl::JoinSession( |
| 262 const mojo::String& presentation_url, | 261 const mojo::String& presentation_url, |
| 263 const mojo::String& presentation_id, | 262 const mojo::String& presentation_id, |
| 264 const NewSessionMojoCallback& callback) { | 263 const NewSessionMojoCallback& callback) { |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 631 |
| 633 void PresentationServiceImpl::DefaultSessionStartContext::Reset() { | 632 void PresentationServiceImpl::DefaultSessionStartContext::Reset() { |
| 634 ScopedVector<DefaultSessionMojoCallback> callbacks; | 633 ScopedVector<DefaultSessionMojoCallback> callbacks; |
| 635 callbacks.swap(callbacks_); | 634 callbacks.swap(callbacks_); |
| 636 for (const auto& callback : callbacks) | 635 for (const auto& callback : callbacks) |
| 637 callback->Run(presentation::PresentationSessionInfoPtr()); | 636 callback->Run(presentation::PresentationSessionInfoPtr()); |
| 638 session_.reset(); | 637 session_.reset(); |
| 639 } | 638 } |
| 640 | 639 |
| 641 } // namespace content | 640 } // namespace content |
| 642 | |
| OLD | NEW |