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 #ifndef CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ |
6 #define CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ | 6 #define CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
11 #include "chrome/browser/media/desktop_media_list_base.h" | 11 #include "chrome/browser/media/desktop_media_list_base.h" |
12 #include "content/public/browser/desktop_media_id.h" | 12 #include "content/public/browser/desktop_media_id.h" |
| 13 #include "ui/gfx/image/image.h" |
13 | 14 |
14 namespace webrtc { | 15 namespace webrtc { |
15 class ScreenCapturer; | 16 class ScreenCapturer; |
16 class WindowCapturer; | 17 class WindowCapturer; |
17 } | 18 } |
18 | 19 |
19 // Implementation of DesktopMediaList that shows native screens and | 20 // Implementation of DesktopMediaList that shows native screens and |
20 // native windows. | 21 // native windows. |
21 class NativeDesktopMediaList : public DesktopMediaListBase { | 22 class NativeDesktopMediaList : public DesktopMediaListBase { |
22 public: | 23 public: |
| 24 typedef std::map<content::DesktopMediaID::Id, content::DesktopMediaID::Id> |
| 25 NativeAuraIdMap; |
| 26 |
23 // Caller may pass NULL for either of the arguments in case when only some | 27 // Caller may pass NULL for either of the arguments in case when only some |
24 // types of sources the model should be populated with (e.g. it will only | 28 // types of sources the model should be populated with (e.g. it will only |
25 // contain windows, if |screen_capturer| is NULL). | 29 // contain windows, if |screen_capturer| is NULL). |
26 NativeDesktopMediaList( | 30 NativeDesktopMediaList( |
27 scoped_ptr<webrtc::ScreenCapturer> screen_capturer, | 31 scoped_ptr<webrtc::ScreenCapturer> screen_capturer, |
28 scoped_ptr<webrtc::WindowCapturer> window_capturer); | 32 scoped_ptr<webrtc::WindowCapturer> window_capturer); |
29 ~NativeDesktopMediaList() override; | 33 ~NativeDesktopMediaList() override; |
30 | 34 |
31 private: | 35 private: |
| 36 typedef std::map<content::DesktopMediaID, uint32_t> ImageHashesMap; |
| 37 |
32 class Worker; | 38 class Worker; |
33 friend class Worker; | 39 friend class Worker; |
34 | 40 |
35 // Refresh() posts a task for the |worker_| to update list of windows and get | 41 // Refresh() posts a task for the |worker_| to update list of windows and get |
36 // thumbnails. Then |worker_| first posts tasks for | 42 // thumbnails. Then |worker_| first posts tasks for |
37 // UpdateObserverSourcesList() with fresh list of sources, then follows with | 43 // UpdateObserverSourcesList() with fresh list of sources, then follows with |
38 // OnSourceThumbnail() for each changed thumbnail and then calls | 44 // OnSourceThumbnail() for each changed thumbnail and then calls |
39 // DelayLaunchNextRefersh() at the end. | 45 // DelayLaunchNextRefersh() at the end. |
40 void Refresh() override; | 46 void Refresh() override; |
41 void OnSourceThumbnail(int index, const gfx::ImageSkia& image); | 47 |
| 48 void OnSourceThumbnailCaptured(int index, const gfx::ImageSkia& image); |
| 49 void FinishRefreshOnUiThreadAndScheduleNext( |
| 50 const std::vector<content::DesktopMediaID>& aura_ids); |
| 51 |
| 52 #if defined(USE_AURA) |
| 53 void CaptureAuraWindowThumbnail(const content::DesktopMediaID& id); |
| 54 void OnAuraThumbnailCaptured(const content::DesktopMediaID& id, |
| 55 const gfx::Image& image); |
| 56 #endif |
42 | 57 |
43 // Task runner used for the |worker_|. | 58 // Task runner used for the |worker_|. |
44 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_; | 59 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_; |
45 | 60 |
46 // An object that does all the work of getting list of sources on a background | 61 // An object that does all the work of getting list of sources on a background |
47 // thread (see |capture_task_runner_|). Destroyed on |capture_task_runner_| | 62 // thread (see |capture_task_runner_|). Destroyed on |capture_task_runner_| |
48 // after the model is destroyed. | 63 // after the model is destroyed. |
49 scoped_ptr<Worker> worker_; | 64 scoped_ptr<Worker> worker_; |
50 | 65 |
| 66 #if defined(USE_AURA) |
| 67 // previous_aura_thumbnail_hashes_ holds thumbanil hash values of aura windows |
| 68 // in the previous refresh. While new_aura_thumbnail_hashes_ has hash values |
| 69 // of the ongoing refresh. Those two maps are used to detect new thumbnails |
| 70 // and changed thumbnails from the previous refresh. |
| 71 ImageHashesMap previous_aura_thumbnail_hashes_; |
| 72 ImageHashesMap new_aura_thumbnail_hashes_; |
| 73 |
| 74 int pending_aura_capture_requests_; |
| 75 #endif |
| 76 |
51 base::WeakPtrFactory<NativeDesktopMediaList> weak_factory_; | 77 base::WeakPtrFactory<NativeDesktopMediaList> weak_factory_; |
52 | 78 |
53 DISALLOW_COPY_AND_ASSIGN(NativeDesktopMediaList); | 79 DISALLOW_COPY_AND_ASSIGN(NativeDesktopMediaList); |
54 }; | 80 }; |
55 | 81 |
56 #endif // CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ | 82 #endif // CHROME_BROWSER_MEDIA_NATIVE_DESKTOP_MEDIA_LIST_H_ |
OLD | NEW |