| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/public/cpp/view_manager/view_manager.h" | 5 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "mojo/public/cpp/application/application.h" | 10 #include "mojo/public/cpp/application/application.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 : nodes_(nodes), | 192 : nodes_(nodes), |
| 193 views_(views) {} | 193 views_(views) {} |
| 194 | 194 |
| 195 private: | 195 private: |
| 196 // Overridden from NodeObserver: | 196 // Overridden from NodeObserver: |
| 197 virtual void OnNodeDestroy( | 197 virtual void OnNodeDestroy( |
| 198 Node* node, | 198 Node* node, |
| 199 NodeObserver::DispositionChangePhase phase) OVERRIDE { | 199 NodeObserver::DispositionChangePhase phase) OVERRIDE { |
| 200 if (phase != NodeObserver::DISPOSITION_CHANGED) | 200 if (phase != NodeObserver::DISPOSITION_CHANGED) |
| 201 return; | 201 return; |
| 202 std::set<Id>::const_iterator it = nodes_->find(node->id()); | 202 std::set<Id>::iterator it = nodes_->find(node->id()); |
| 203 if (it != nodes_->end()) | 203 if (it != nodes_->end()) |
| 204 nodes_->erase(it); | 204 nodes_->erase(it); |
| 205 if (CanQuit()) | 205 if (CanQuit()) |
| 206 QuitRunLoop(); | 206 QuitRunLoop(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Overridden from ViewObserver: | 209 // Overridden from ViewObserver: |
| 210 virtual void OnViewDestroy( | 210 virtual void OnViewDestroy( |
| 211 View* view, | 211 View* view, |
| 212 ViewObserver::DispositionChangePhase phase) OVERRIDE { | 212 ViewObserver::DispositionChangePhase phase) OVERRIDE { |
| 213 if (phase != ViewObserver::DISPOSITION_CHANGED) | 213 if (phase != ViewObserver::DISPOSITION_CHANGED) |
| 214 return; | 214 return; |
| 215 std::set<Id>::const_iterator it = views_->find(view->id()); | 215 std::set<Id>::iterator it = views_->find(view->id()); |
| 216 if (it != views_->end()) | 216 if (it != views_->end()) |
| 217 views_->erase(it); | 217 views_->erase(it); |
| 218 if (CanQuit()) | 218 if (CanQuit()) |
| 219 QuitRunLoop(); | 219 QuitRunLoop(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 bool CanQuit() { | 222 bool CanQuit() { |
| 223 return (!nodes_ || nodes_->empty()) && (!views_ || views_->empty()); | 223 return (!nodes_ || nodes_->empty()) && (!views_ || views_->empty()); |
| 224 } | 224 } |
| 225 | 225 |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 770 |
| 771 EXPECT_EQ(node1_in_embedded->children().front(), | 771 EXPECT_EQ(node1_in_embedded->children().front(), |
| 772 embedded->GetNodeById(node11->id())); | 772 embedded->GetNodeById(node11->id())); |
| 773 EXPECT_EQ(node1_in_embedded->children().back(), | 773 EXPECT_EQ(node1_in_embedded->children().back(), |
| 774 embedded->GetNodeById(node12->id())); | 774 embedded->GetNodeById(node12->id())); |
| 775 } | 775 } |
| 776 } | 776 } |
| 777 | 777 |
| 778 } // namespace view_manager | 778 } // namespace view_manager |
| 779 } // namespace mojo | 779 } // namespace mojo |
| OLD | NEW |