OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/contents/blimp_contents_manager.h" | 5 #include "blimp/client/core/contents/blimp_contents_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" | 10 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 BlimpContentsDeletionObserver* observer = observer_map_.at(id).get(); | 90 BlimpContentsDeletionObserver* observer = observer_map_.at(id).get(); |
91 // If the BlimpContents that the observer tracks is empty, it means | 91 // If the BlimpContents that the observer tracks is empty, it means |
92 // OnContentsDestroyed was called on this observer, but the task to erase | 92 // OnContentsDestroyed was called on this observer, but the task to erase |
93 // the observer from the map hasn't been run. | 93 // the observer from the map hasn't been run. |
94 if (observer->blimp_contents()) | 94 if (observer->blimp_contents()) |
95 return static_cast<BlimpContentsImpl*>(observer->blimp_contents()); | 95 return static_cast<BlimpContentsImpl*>(observer->blimp_contents()); |
96 | 96 |
97 return nullptr; | 97 return nullptr; |
98 } | 98 } |
99 | 99 |
| 100 std::vector<BlimpContentsImpl*> |
| 101 BlimpContentsManager::GetAllActiveBlimpContents() { |
| 102 std::vector<BlimpContentsImpl*> all_blimp_contents; |
| 103 for (const auto& item : observer_map_) { |
| 104 BlimpContentsImpl* blimp_contents = |
| 105 static_cast<BlimpContentsImpl*>(item.second.get()->blimp_contents()); |
| 106 if (!blimp_contents) { |
| 107 continue; |
| 108 } |
| 109 all_blimp_contents.push_back(blimp_contents); |
| 110 } |
| 111 return all_blimp_contents; |
| 112 } |
| 113 |
100 int BlimpContentsManager::CreateBlimpContentsId() { | 114 int BlimpContentsManager::CreateBlimpContentsId() { |
101 return next_blimp_contents_id_++; | 115 return next_blimp_contents_id_++; |
102 } | 116 } |
103 | 117 |
104 void BlimpContentsManager::EraseObserverFromMap(int id) { | 118 void BlimpContentsManager::EraseObserverFromMap(int id) { |
105 observer_map_.erase(id); | 119 observer_map_.erase(id); |
106 } | 120 } |
107 | 121 |
108 void BlimpContentsManager::OnContentsDestroyed(BlimpContents* contents) { | 122 void BlimpContentsManager::OnContentsDestroyed(BlimpContents* contents) { |
109 DCHECK(tab_exists_); | 123 DCHECK(tab_exists_); |
(...skipping 10 matching lines...) Expand all Loading... |
120 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, | 134 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, |
121 this->GetWeakPtr(), id)); | 135 this->GetWeakPtr(), id)); |
122 } | 136 } |
123 | 137 |
124 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { | 138 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { |
125 return weak_ptr_factory_.GetWeakPtr(); | 139 return weak_ptr_factory_.GetWeakPtr(); |
126 } | 140 } |
127 | 141 |
128 } // namespace client | 142 } // namespace client |
129 } // namespace blimp | 143 } // namespace blimp |
OLD | NEW |