OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/native_desktop_media_list.h" | 5 #include "chrome/browser/media/native_desktop_media_list.h" |
6 | 6 |
7 #include "base/hash.h" | 7 #include "base/hash.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
10 #include "chrome/browser/media/desktop_media_list_observer.h" | 10 #include "chrome/browser/media/desktop_media_list_observer.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 | 89 |
90 void Refresh(const DesktopMediaID::Id& view_dialog_id); | 90 void Refresh(const DesktopMediaID::Id& view_dialog_id); |
91 | 91 |
92 void RefreshThumbnails(const std::vector<DesktopMediaID>& native_ids, | 92 void RefreshThumbnails(const std::vector<DesktopMediaID>& native_ids, |
93 const gfx::Size& thumbnail_size); | 93 const gfx::Size& thumbnail_size); |
94 | 94 |
95 private: | 95 private: |
96 typedef std::map<DesktopMediaID, uint32_t> ImageHashesMap; | 96 typedef std::map<DesktopMediaID, uint32_t> ImageHashesMap; |
97 | 97 |
98 // webrtc::DesktopCapturer::Callback interface. | 98 // webrtc::DesktopCapturer::Callback interface. |
99 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; | 99 void OnCaptureResult(webrtc::DesktopCapturer::Result result, |
100 std::unique_ptr<webrtc::DesktopFrame> frame) override; | |
100 | 101 |
101 base::WeakPtr<NativeDesktopMediaList> media_list_; | 102 base::WeakPtr<NativeDesktopMediaList> media_list_; |
102 | 103 |
103 std::unique_ptr<webrtc::ScreenCapturer> screen_capturer_; | 104 std::unique_ptr<webrtc::ScreenCapturer> screen_capturer_; |
104 std::unique_ptr<webrtc::WindowCapturer> window_capturer_; | 105 std::unique_ptr<webrtc::WindowCapturer> window_capturer_; |
105 | 106 |
106 std::unique_ptr<webrtc::DesktopFrame> current_frame_; | 107 std::unique_ptr<webrtc::DesktopFrame> current_frame_; |
107 | 108 |
108 ImageHashesMap image_hashes_; | 109 ImageHashesMap image_hashes_; |
109 | 110 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 } | 219 } |
219 | 220 |
220 image_hashes_.swap(new_image_hashes); | 221 image_hashes_.swap(new_image_hashes); |
221 | 222 |
222 BrowserThread::PostTask( | 223 BrowserThread::PostTask( |
223 BrowserThread::UI, FROM_HERE, | 224 BrowserThread::UI, FROM_HERE, |
224 base::Bind(&NativeDesktopMediaList::UpdateNativeThumbnailsFinished, | 225 base::Bind(&NativeDesktopMediaList::UpdateNativeThumbnailsFinished, |
225 media_list_)); | 226 media_list_)); |
226 } | 227 } |
227 | 228 |
228 void NativeDesktopMediaList::Worker::OnCaptureCompleted( | 229 void NativeDesktopMediaList::Worker::OnCaptureResult( |
229 webrtc::DesktopFrame* frame) { | 230 webrtc::DesktopCapturer::Result result, |
230 current_frame_.reset(frame); | 231 std::unique_ptr<webrtc::DesktopFrame> frame) { |
232 if (frame) | |
233 current_frame_ = std::move(frame); | |
Wez
2016/06/17 05:57:16
You're changing the semantics such that the deskto
Sergey Ulanov
2016/06/17 14:59:54
You are right. current_frame_ may actually be from
| |
231 } | 234 } |
232 | 235 |
233 NativeDesktopMediaList::NativeDesktopMediaList( | 236 NativeDesktopMediaList::NativeDesktopMediaList( |
234 std::unique_ptr<webrtc::ScreenCapturer> screen_capturer, | 237 std::unique_ptr<webrtc::ScreenCapturer> screen_capturer, |
235 std::unique_ptr<webrtc::WindowCapturer> window_capturer) | 238 std::unique_ptr<webrtc::WindowCapturer> window_capturer) |
236 : DesktopMediaListBase( | 239 : DesktopMediaListBase( |
237 base::TimeDelta::FromMilliseconds(kDefaultUpdatePeriod)), | 240 base::TimeDelta::FromMilliseconds(kDefaultUpdatePeriod)), |
238 weak_factory_(this) { | 241 weak_factory_(this) { |
239 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool(); | 242 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool(); |
240 capture_task_runner_ = worker_pool->GetSequencedTaskRunner( | 243 capture_task_runner_ = worker_pool->GetSequencedTaskRunner( |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 if (pending_aura_capture_requests_ == 0) { | 368 if (pending_aura_capture_requests_ == 0) { |
366 previous_aura_thumbnail_hashes_ = std::move(new_aura_thumbnail_hashes_); | 369 previous_aura_thumbnail_hashes_ = std::move(new_aura_thumbnail_hashes_); |
367 // Schedule next refresh if aura thumbnail captures finished after native | 370 // Schedule next refresh if aura thumbnail captures finished after native |
368 // thumbnail captures. | 371 // thumbnail captures. |
369 if (!pending_native_thumbnail_capture_) | 372 if (!pending_native_thumbnail_capture_) |
370 ScheduleNextRefresh(); | 373 ScheduleNextRefresh(); |
371 } | 374 } |
372 } | 375 } |
373 | 376 |
374 #endif // defined(USE_AURA) | 377 #endif // defined(USE_AURA) |
OLD | NEW |