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 "chrome/browser/media/router/offscreen_presentation_manager.h" | 5 #include "chrome/browser/media/router/offscreen_presentation_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id | 54 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id |
55 << ", [render_frame_host_id]: " << render_frame_host_id.second; | 55 << ", [render_frame_host_id]: " << render_frame_host_id.second; |
56 DCHECK(thread_checker_.CalledOnValidThread()); | 56 DCHECK(thread_checker_.CalledOnValidThread()); |
57 | 57 |
58 auto it = offscreen_presentations_.find(presentation_id); | 58 auto it = offscreen_presentations_.find(presentation_id); |
59 if (it == offscreen_presentations_.end()) | 59 if (it == offscreen_presentations_.end()) |
60 return; | 60 return; |
61 | 61 |
62 // Remove presentation if no controller and receiver. | 62 // Remove presentation if no controller and receiver. |
63 it->second->UnregisterController(render_frame_host_id); | 63 it->second->UnregisterController(render_frame_host_id); |
64 if (it->second->pending_controllers_.size() == 0 && | 64 if (!it->second->IsValid()) { |
65 it->second->receiver_callback_.is_null()) | 65 DLOG(WARNING) << __func__ << " no receiver callback has been registered to " |
| 66 << "[presentation_id]: " << presentation_id; |
66 offscreen_presentations_.erase(presentation_id); | 67 offscreen_presentations_.erase(presentation_id); |
| 68 } |
67 } | 69 } |
68 | 70 |
69 void OffscreenPresentationManager::OnOffscreenPresentationReceiverCreated( | 71 void OffscreenPresentationManager::OnOffscreenPresentationReceiverCreated( |
70 const std::string& presentation_id, | 72 const std::string& presentation_id, |
71 const GURL& presentation_url, | 73 const GURL& presentation_url, |
72 const content::ReceiverConnectionAvailableCallback& receiver_callback) { | 74 const content::ReceiverConnectionAvailableCallback& receiver_callback) { |
73 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id; | 75 DVLOG(2) << __FUNCTION__ << " [presentation_id]: " << presentation_id; |
74 DCHECK(thread_checker_.CalledOnValidThread()); | 76 DCHECK(thread_checker_.CalledOnValidThread()); |
75 auto presentation = | 77 auto presentation = |
76 GetOrCreateOffscreenPresentation(presentation_id, presentation_url); | 78 GetOrCreateOffscreenPresentation(presentation_id, presentation_url); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 124 } |
123 receiver_callback_ = receiver_callback; | 125 receiver_callback_ = receiver_callback; |
124 pending_controllers_.clear(); | 126 pending_controllers_.clear(); |
125 } | 127 } |
126 | 128 |
127 bool OffscreenPresentationManager::OffscreenPresentation::IsValid() { | 129 bool OffscreenPresentationManager::OffscreenPresentation::IsValid() { |
128 return !(pending_controllers_.size() == 0 && receiver_callback_.is_null()); | 130 return !(pending_controllers_.size() == 0 && receiver_callback_.is_null()); |
129 } | 131 } |
130 | 132 |
131 } // namespace media_router | 133 } // namespace media_router |
OLD | NEW |