Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: blimp/client/core/contents/blimp_contents_manager.cc

Issue 2371503002: Add Blimp feedback data about visible BlimpContents. (Closed)
Patch Set: Cleanup BlimpContentsManagerTest. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 all_blimp_contents.push_back(
David Trainor- moved to gerrit 2016/09/27 03:49:26 Check if the contents is null or not. We do a pos
nyquist 2016/09/27 06:21:29 Wow! Good catch, thanks! Fixed now. I also of cour
105 static_cast<BlimpContentsImpl*>(item.second.get()->blimp_contents()));
106 }
107 return all_blimp_contents;
108 }
109
100 int BlimpContentsManager::CreateBlimpContentsId() { 110 int BlimpContentsManager::CreateBlimpContentsId() {
101 return next_blimp_contents_id_++; 111 return next_blimp_contents_id_++;
102 } 112 }
103 113
104 void BlimpContentsManager::EraseObserverFromMap(int id) { 114 void BlimpContentsManager::EraseObserverFromMap(int id) {
105 observer_map_.erase(id); 115 observer_map_.erase(id);
106 } 116 }
107 117
108 void BlimpContentsManager::OnContentsDestroyed(BlimpContents* contents) { 118 void BlimpContentsManager::OnContentsDestroyed(BlimpContents* contents) {
109 DCHECK(tab_exists_); 119 DCHECK(tab_exists_);
(...skipping 10 matching lines...) Expand all
120 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, 130 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap,
121 this->GetWeakPtr(), id)); 131 this->GetWeakPtr(), id));
122 } 132 }
123 133
124 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { 134 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() {
125 return weak_ptr_factory_.GetWeakPtr(); 135 return weak_ptr_factory_.GetWeakPtr();
126 } 136 }
127 137
128 } // namespace client 138 } // namespace client
129 } // namespace blimp 139 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/contents/blimp_contents_manager.h ('k') | blimp/client/core/contents/blimp_contents_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698