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