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 #include "chrome/browser/media/desktop_media_picker_model.h" | 5 #include "chrome/browser/media/desktop_media_picker_model.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 DCHECK(!observer_); | 251 DCHECK(!observer_); |
252 DCHECK(screen_capturer_ || window_capturer_); | 252 DCHECK(screen_capturer_ || window_capturer_); |
253 | 253 |
254 observer_ = observer; | 254 observer_ = observer; |
255 | 255 |
256 worker_.reset(new Worker(weak_factory_.GetWeakPtr(), | 256 worker_.reset(new Worker(weak_factory_.GetWeakPtr(), |
257 screen_capturer_.Pass(), window_capturer_.Pass())); | 257 screen_capturer_.Pass(), window_capturer_.Pass())); |
258 Refresh(); | 258 Refresh(); |
259 } | 259 } |
260 | 260 |
| 261 int DesktopMediaPickerModel::source_count() const { |
| 262 return sources_.size(); |
| 263 } |
| 264 |
| 265 const DesktopMediaPickerModel::Source& DesktopMediaPickerModel::source( |
| 266 int index) const { |
| 267 return sources_[index]; |
| 268 } |
| 269 |
261 // static | 270 // static |
262 bool DesktopMediaPickerModel::CompareSources(const SourceDescription& a, | 271 bool DesktopMediaPickerModel::CompareSources(const SourceDescription& a, |
263 const SourceDescription& b) { | 272 const SourceDescription& b) { |
264 return a.id < b.id; | 273 return a.id < b.id; |
265 } | 274 } |
266 | 275 |
267 void DesktopMediaPickerModel::Refresh() { | 276 void DesktopMediaPickerModel::Refresh() { |
268 capture_task_runner_->PostTask( | 277 capture_task_runner_->PostTask( |
269 FROM_HERE, base::Bind(&Worker::Refresh, base::Unretained(worker_.get()), | 278 FROM_HERE, base::Bind(&Worker::Refresh, base::Unretained(worker_.get()), |
270 thumbnail_size_)); | 279 thumbnail_size_)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 sources_[index].thumbnail = image; | 315 sources_[index].thumbnail = image; |
307 observer_->OnSourceThumbnailChanged(index); | 316 observer_->OnSourceThumbnailChanged(index); |
308 } | 317 } |
309 | 318 |
310 void DesktopMediaPickerModel::OnRefreshFinished() { | 319 void DesktopMediaPickerModel::OnRefreshFinished() { |
311 BrowserThread::PostDelayedTask( | 320 BrowserThread::PostDelayedTask( |
312 BrowserThread::UI, FROM_HERE, | 321 BrowserThread::UI, FROM_HERE, |
313 base::Bind(&DesktopMediaPickerModel::Refresh, weak_factory_.GetWeakPtr()), | 322 base::Bind(&DesktopMediaPickerModel::Refresh, weak_factory_.GetWeakPtr()), |
314 update_period_); | 323 update_period_); |
315 } | 324 } |
OLD | NEW |