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

Unified Diff: chrome/browser/media/native_desktop_media_list.cc

Issue 1828303003: Modify unit tests for NativeDesktopMediaList to cover aura window capture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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: chrome/browser/media/native_desktop_media_list.cc
diff --git a/chrome/browser/media/native_desktop_media_list.cc b/chrome/browser/media/native_desktop_media_list.cc
index 36b8a74c860a2f871a5e47ac252b6c39deb8e03e..f1d801c1d8122a154e57288acd156c93e53332bb 100644
--- a/chrome/browser/media/native_desktop_media_list.cc
+++ b/chrome/browser/media/native_desktop_media_list.cc
@@ -249,9 +249,9 @@ NativeDesktopMediaList::~NativeDesktopMediaList() {
void NativeDesktopMediaList::Refresh() {
#if defined(USE_AURA)
- pending_aura_capture_requests_ = 0;
+ DCHECK_EQ(pending_aura_capture_requests_, 0);
+ DCHECK(!pending_native_thumbnail_capture_);
new_aura_thumbnail_hashes_.clear();
- pending_native_thumbnail_capture_ = true;
#endif
capture_task_runner_->PostTask(
@@ -262,7 +262,11 @@ void NativeDesktopMediaList::Refresh() {
void NativeDesktopMediaList::RefreshForAuraWindows(
std::vector<SourceDescription> sources) {
#if defined(USE_AURA)
+ // Associate aura id with native id.
for (auto& source : sources) {
+ if (source.id.type != DesktopMediaID::TYPE_WINDOW)
+ continue;
+
aura::Window* aura_window = NULL;
#if defined(OS_WIN)
aura_window = views::DesktopWindowTreeHostWin::GetContentWindowForHWND(
@@ -271,7 +275,6 @@ void NativeDesktopMediaList::RefreshForAuraWindows(
aura_window =
views::DesktopWindowTreeHostX11::GetContentWindowForXID(source.id.id);
#endif // defined(USE_X11) && !defined(OS_CHROMEOS)
- // Associate aura id with native id.
if (aura_window) {
DesktopMediaID aura_id = DesktopMediaID::RegisterAuraWindow(
DesktopMediaID::TYPE_WINDOW, aura_window);
@@ -282,6 +285,13 @@ void NativeDesktopMediaList::RefreshForAuraWindows(
UpdateSourcesList(sources);
+ // OnAuraThumbnailCaptured() and UpdateNativeThumbnailsFinished() are
+ // guaranteed to be excuted after RefreshForAuraWindows() and
+ // CaptureAuraWindowThumbnail() in the browser UI thread.
+ // Therefore pending_aura_capture_requests_ will be set the number of aura
+ // windows to be captured and pending_native_thumbnail_capture_ will be set
+ // true if native thumbnail capture is needed before OnAuraThumbnailCaptured()
+ // or UpdateNativeThumbnailsFinished() are called.
std::vector<DesktopMediaID> native_ids;
for (const auto& source : sources) {
#if defined(USE_AURA)
@@ -293,10 +303,15 @@ void NativeDesktopMediaList::RefreshForAuraWindows(
native_ids.push_back(source.id);
}
- capture_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&Worker::RefreshThumbnails, base::Unretained(worker_.get()),
- native_ids, thumbnail_size_));
+ if (native_ids.size() > 0) {
+#if defined(USE_AURA)
+ pending_native_thumbnail_capture_ = true;
+#endif
+ capture_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&Worker::RefreshThumbnails, base::Unretained(worker_.get()),
+ native_ids, thumbnail_size_));
+ }
}
void NativeDesktopMediaList::UpdateNativeThumbnailsFinished() {
« no previous file with comments | « chrome/browser/media/native_desktop_media_list.h ('k') | chrome/browser/media/native_desktop_media_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698