| 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 |
| 75 class DesktopMediaPickerModelImpl : public DesktopMediaPickerModel { |
| 76 public: |
| 77 // Caller may pass NULL for either of the arguments in case when only some |
| 78 // types of sources the model should be populated with (e.g. it will only |
| 79 // contain windows, if |screen_capturer| is NULL). |
| 80 DesktopMediaPickerModelImpl( |
| 81 scoped_ptr<webrtc::ScreenCapturer> screen_capturer, |
| 82 scoped_ptr<webrtc::WindowCapturer> window_capturer); |
| 83 virtual ~DesktopMediaPickerModelImpl(); |
| 84 |
| 85 // DesktopMediaPickerModelInterface: |
| 86 virtual void SetUpdatePeriod(base::TimeDelta period) OVERRIDE; |
| 87 virtual void SetThumbnailSize(const gfx::Size& thumbnail_size) OVERRIDE; |
| 88 virtual void StartUpdating(Observer* observer) OVERRIDE; |
| 89 virtual int source_count() const OVERRIDE; |
| 90 virtual const Source& source(int index) const OVERRIDE; |
| 78 | 91 |
| 79 private: | 92 private: |
| 80 class Worker; | 93 class Worker; |
| 81 friend class Worker; | 94 friend class Worker; |
| 82 | 95 |
| 83 // Struct used to represent sources list the model gets from the Worker. | 96 // Struct used to represent sources list the model gets from the Worker. |
| 84 struct SourceDescription { | 97 struct SourceDescription { |
| 85 SourceDescription(content::DesktopMediaID id, const string16& name); | 98 SourceDescription(content::DesktopMediaID id, const string16& name); |
| 86 | 99 |
| 87 content::DesktopMediaID id; | 100 content::DesktopMediaID id; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_; | 133 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_; |
| 121 | 134 |
| 122 // An object that does all the work of getting list of sources on a background | 135 // 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_| | 136 // thread (see |capture_task_runner_|). Destroyed on |capture_task_runner_| |
| 124 // after the model is destroyed. | 137 // after the model is destroyed. |
| 125 scoped_ptr<Worker> worker_; | 138 scoped_ptr<Worker> worker_; |
| 126 | 139 |
| 127 // Current list of sources. | 140 // Current list of sources. |
| 128 std::vector<Source> sources_; | 141 std::vector<Source> sources_; |
| 129 | 142 |
| 130 base::WeakPtrFactory<DesktopMediaPickerModel> weak_factory_; | 143 base::WeakPtrFactory<DesktopMediaPickerModelImpl> weak_factory_; |
| 131 | 144 |
| 132 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerModel); | 145 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerModelImpl); |
| 133 }; | 146 }; |
| 134 | 147 |
| 135 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_PICKER_MODEL_H_ | 148 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_PICKER_MODEL_H_ |
| OLD | NEW |