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_DESKTOP_MEDIA_PICKER_MODEL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_PICKER_MODEL_H_ |
6 #define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_PICKER_MODEL_H_ | 6 #define CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_PICKER_MODEL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 // Id of the source. | 42 // Id of the source. |
43 content::DesktopMediaID id; | 43 content::DesktopMediaID id; |
44 | 44 |
45 // Name of the source that should be shown to the user. | 45 // Name of the source that should be shown to the user. |
46 string16 name; | 46 string16 name; |
47 | 47 |
48 // The thumbnail for the source. | 48 // The thumbnail for the source. |
49 gfx::ImageSkia thumbnail; | 49 gfx::ImageSkia thumbnail; |
50 }; | 50 }; |
51 | 51 |
52 // Caller may pass NULL for either of the arguments in case when only some | 52 virtual ~DesktopMediaPickerModel() {} |
53 // types of sources the model should be populated with (e.g. it will only | |
54 // contain windows, if |screen_capturer| is NULL). | |
55 DesktopMediaPickerModel(scoped_ptr<webrtc::ScreenCapturer> screen_capturer, | |
56 scoped_ptr<webrtc::WindowCapturer> window_capturer); | |
57 virtual ~DesktopMediaPickerModel(); | |
58 | 53 |
59 // Sets time interval between updates. By default list of sources and their | 54 // Sets time interval between updates. By default list of sources and their |
60 // thumbnail are updated once per second. If called after StartUpdating() then | 55 // thumbnail are updated once per second. If called after StartUpdating() then |
61 // it will take effect only after the next update. | 56 // it will take effect only after the next update. |
62 void SetUpdatePeriod(base::TimeDelta period); | 57 virtual void SetUpdatePeriod(base::TimeDelta period) = 0; |
63 | 58 |
64 // Sets size to which the thumbnails should be scaled. If called after | 59 // Sets size to which the thumbnails should be scaled. If called after |
65 // StartUpdating() then some thumbnails may be still scaled to the old size | 60 // StartUpdating() then some thumbnails may be still scaled to the old size |
66 // until they are updated. | 61 // until they are updated. |
67 void SetThumbnailSize(const gfx::Size& thumbnail_size); | 62 virtual void SetThumbnailSize(const gfx::Size& thumbnail_size) = 0; |
68 | 63 |
69 // Starts updating the model. The model is initially empty, so OnSourceAdded() | 64 // Starts updating the model. The model is initially empty, so OnSourceAdded() |
70 // notifications will be generated for each existing source as it is | 65 // notifications will be generated for each existing source as it is |
71 // enumerated. After the initial enumeration the model will be refreshed based | 66 // enumerated. After the initial enumeration the model will be refreshed based |
72 // on the update period, and notifications generated only for changes in the | 67 // on the update period, and notifications generated only for changes in the |
73 // model. | 68 // model. |
74 void StartUpdating(Observer* observer); | 69 virtual void StartUpdating(Observer* observer) = 0; |
75 | 70 |
76 int source_count() const { return sources_.size(); } | 71 virtual int source_count() const = 0; |
77 const Source& source(int index) const { return sources_.at(index); } | 72 virtual const Source& source(int index) const = 0; |
73 | |
74 private: | |
75 DISALLOW_ASSIGN(DesktopMediaPickerModel); | |
Sergey Ulanov
2013/09/04 22:50:06
nit: Why not DISALLOW_COPY_AND_ASSIGN? In either c
dcaiafa
2013/09/04 23:00:27
Done.
| |
76 }; | |
77 | |
78 class DesktopMediaPickerModelImpl : public DesktopMediaPickerModel { | |
79 public: | |
80 // Caller may pass NULL for either of the arguments in case when only some | |
81 // types of sources the model should be populated with (e.g. it will only | |
82 // contain windows, if |screen_capturer| is NULL). | |
83 DesktopMediaPickerModelImpl( | |
84 scoped_ptr<webrtc::ScreenCapturer> screen_capturer, | |
85 scoped_ptr<webrtc::WindowCapturer> window_capturer); | |
86 virtual ~DesktopMediaPickerModelImpl(); | |
87 | |
88 // DesktopMediaPickerModelInterface: | |
89 virtual void SetUpdatePeriod(base::TimeDelta period) OVERRIDE; | |
90 virtual void SetThumbnailSize(const gfx::Size& thumbnail_size) OVERRIDE; | |
91 virtual void StartUpdating(Observer* observer) OVERRIDE; | |
92 virtual int source_count() const OVERRIDE; | |
93 virtual const Source& source(int index) const OVERRIDE; | |
78 | 94 |
79 private: | 95 private: |
80 class Worker; | 96 class Worker; |
81 friend class Worker; | 97 friend class Worker; |
82 | 98 |
83 // Struct used to represent sources list the model gets from the Worker. | 99 // Struct used to represent sources list the model gets from the Worker. |
84 struct SourceDescription { | 100 struct SourceDescription { |
85 SourceDescription(content::DesktopMediaID id, const string16& name); | 101 SourceDescription(content::DesktopMediaID id, const string16& name); |
86 | 102 |
87 content::DesktopMediaID id; | 103 content::DesktopMediaID id; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_; | 136 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_; |
121 | 137 |
122 // An object that does all the work of getting list of sources on a background | 138 // An object that does all the work of getting list of sources on a background |
123 // thread (see |capture_task_runner_|). Destroyed on |capture_task_runner_| | 139 // thread (see |capture_task_runner_|). Destroyed on |capture_task_runner_| |
124 // after the model is destroyed. | 140 // after the model is destroyed. |
125 scoped_ptr<Worker> worker_; | 141 scoped_ptr<Worker> worker_; |
126 | 142 |
127 // Current list of sources. | 143 // Current list of sources. |
128 std::vector<Source> sources_; | 144 std::vector<Source> sources_; |
129 | 145 |
130 base::WeakPtrFactory<DesktopMediaPickerModel> weak_factory_; | 146 base::WeakPtrFactory<DesktopMediaPickerModelImpl> weak_factory_; |
131 | 147 |
132 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerModel); | 148 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerModelImpl); |
133 }; | 149 }; |
134 | 150 |
135 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_PICKER_MODEL_H_ | 151 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_PICKER_MODEL_H_ |
OLD | NEW |