Chromium Code Reviews| Index: chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc |
| diff --git a/chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc b/chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c0c510fcc020fbf9e4ff8e928eaa35029a31096e |
| --- /dev/null |
| +++ b/chrome/browser/media/router/receiver_presentation_service_delegate_impl.cc |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/media/router/receiver_presentation_service_delegate_impl.h" |
| + |
| +#include "content/public/browser/render_frame_host.h" |
| +#include "content/public/browser/render_process_host.h" |
| +#include "url/gurl.h" |
|
mark a. foltz
2016/11/15 23:41:46
None of these #includes seem to be used.
zhaobin
2016/11/16 18:02:41
Done.
|
| + |
| +DEFINE_WEB_CONTENTS_USER_DATA_KEY( |
| + media_router::ReceiverPresentationServiceDelegateImpl); |
| + |
| +using content::RenderFrameHost; |
| + |
| +namespace media_router { |
| + |
| +// static |
| +void ReceiverPresentationServiceDelegateImpl::CreateForWebContents( |
| + content::WebContents* web_contents, |
| + const std::string& presentation_id) { |
| + DCHECK(web_contents); |
| + |
| + if (FromWebContents(web_contents)) |
| + return; |
| + |
| + web_contents->SetUserData(UserDataKey(), |
| + new ReceiverPresentationServiceDelegateImpl( |
| + web_contents, presentation_id)); |
| +} |
| + |
| +ReceiverPresentationServiceDelegateImpl:: |
| + ~ReceiverPresentationServiceDelegateImpl() {} |
| + |
| +void ReceiverPresentationServiceDelegateImpl::AddObserver( |
| + int render_process_id, |
| + int render_frame_id, |
| + content::PresentationServiceDelegateBase::Observer* observer) { |
| + PresentationServiceDelegateBaseImpl::AddObserver(render_process_id, |
|
mark a. foltz
2016/11/15 23:41:46
Since this just calling through to the base class
zhaobin
2016/11/16 18:02:41
Done.
|
| + render_frame_id, observer); |
| +} |
| + |
| +void ReceiverPresentationServiceDelegateImpl::RemoveObserver( |
| + int render_process_id, |
| + int render_frame_id) { |
| + PresentationServiceDelegateBaseImpl::RemoveObserver(render_process_id, |
| + render_frame_id); |
| +} |
| + |
| +void ReceiverPresentationServiceDelegateImpl::Reset(int render_process_id, |
| + int render_frame_id) { |
| + DVLOG(2) << __FUNCTION__ << render_process_id << ", " << render_frame_id; |
| + offscreen_presentation_manager_->OnOffscreenPresentationReceiverTerminated( |
| + presentation_id_); |
| +} |
| + |
| +ReceiverPresentationServiceDelegateImpl:: |
| + ReceiverPresentationServiceDelegateImpl(content::WebContents* web_contents, |
| + const std::string& presentation_id) |
| + : web_contents_(web_contents), |
| + presentation_id_(presentation_id), |
| + offscreen_presentation_manager_( |
| + OffscreenPresentationManagerFactory:: |
| + GetOrCreateForReceiverBrowserContext(web_contents_)) { |
| + DCHECK(web_contents_); |
| + DCHECK(!presentation_id.empty()); |
| + DCHECK(offscreen_presentation_manager_); |
| +} |
| + |
| +void ReceiverPresentationServiceDelegateImpl:: |
| + RegisterReceiverConnectionAvailableCallback( |
| + const content::ReceiverConnectionAvailableCallback& |
| + receiver_available_callback) { |
| + offscreen_presentation_manager_->OnOffscreenPresentationReceiverCreated( |
| + presentation_id_, web_contents_->GetLastCommittedURL(), |
| + receiver_available_callback); |
| +} |
| + |
| +} // namespace media_router |