| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Sets size to which the thumbnails should be scaled. If called after | 64 // 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 | 65 // StartUpdating() then some thumbnails may be still scaled to the old size |
| 66 // until they are updated. | 66 // until they are updated. |
| 67 void SetThumbnailSize(const gfx::Size& thumbnail_size); | 67 void SetThumbnailSize(const gfx::Size& thumbnail_size); |
| 68 | 68 |
| 69 // Starts updating the model. The model is initially empty, so OnSourceAdded() | 69 // Starts updating the model. The model is initially empty, so OnSourceAdded() |
| 70 // notifications will be generated for each existing source as it is | 70 // notifications will be generated for each existing source as it is |
| 71 // enumerated. After the initial enumeration the model will be refreshed based | 71 // enumerated. After the initial enumeration the model will be refreshed based |
| 72 // on the update period, and notifications generated only for changes in the | 72 // on the update period, and notifications generated only for changes in the |
| 73 // model. | 73 // model. |
| 74 void StartUpdating(Observer* observer); | 74 virtual void StartUpdating(Observer* observer); |
| 75 | 75 |
| 76 int source_count() const { return sources_.size(); } | 76 int source_count() const { return sources_.size(); } |
| 77 const Source& source(int index) const { return sources_.at(index); } | 77 const Source& source(int index) const { return sources_.at(index); } |
| 78 | 78 |
| 79 protected: |
| 80 // Current list of sources. |
| 81 std::vector<Source> sources_; |
| 82 |
| 79 private: | 83 private: |
| 80 class Worker; | 84 class Worker; |
| 81 friend class Worker; | 85 friend class Worker; |
| 82 | 86 |
| 83 // Struct used to represent sources list the model gets from the Worker. | 87 // Struct used to represent sources list the model gets from the Worker. |
| 84 struct SourceDescription { | 88 struct SourceDescription { |
| 85 SourceDescription(content::DesktopMediaID id, const string16& name); | 89 SourceDescription(content::DesktopMediaID id, const string16& name); |
| 86 | 90 |
| 87 content::DesktopMediaID id; | 91 content::DesktopMediaID id; |
| 88 string16 name; | 92 string16 name; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 117 Observer* observer_; | 121 Observer* observer_; |
| 118 | 122 |
| 119 // Task runner used for the |worker_|. | 123 // Task runner used for the |worker_|. |
| 120 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_; | 124 scoped_refptr<base::SequencedTaskRunner> capture_task_runner_; |
| 121 | 125 |
| 122 // An object that does all the work of getting list of sources on a background | 126 // 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_| | 127 // thread (see |capture_task_runner_|). Destroyed on |capture_task_runner_| |
| 124 // after the model is destroyed. | 128 // after the model is destroyed. |
| 125 scoped_ptr<Worker> worker_; | 129 scoped_ptr<Worker> worker_; |
| 126 | 130 |
| 127 // Current list of sources. | |
| 128 std::vector<Source> sources_; | |
| 129 | |
| 130 base::WeakPtrFactory<DesktopMediaPickerModel> weak_factory_; | 131 base::WeakPtrFactory<DesktopMediaPickerModel> weak_factory_; |
| 131 | 132 |
| 132 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerModel); | 133 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerModel); |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_PICKER_MODEL_H_ | 136 #endif // CHROME_BROWSER_MEDIA_DESKTOP_MEDIA_PICKER_MODEL_H_ |
| OLD | NEW |