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/lib/view_manager_client_impl.h" | 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/public/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
10 #include "mojo/public/cpp/application/connect.h" | 10 #include "mojo/public/cpp/application/connect.h" |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 525 |
526 ViewManagerClientImpl::ViewManagerClientImpl(ApplicationConnection* connection, | 526 ViewManagerClientImpl::ViewManagerClientImpl(ApplicationConnection* connection, |
527 ViewManagerDelegate* delegate) | 527 ViewManagerDelegate* delegate) |
528 : connected_(false), | 528 : connected_(false), |
529 connection_id_(0), | 529 connection_id_(0), |
530 next_id_(1), | 530 next_id_(1), |
531 delegate_(delegate), | 531 delegate_(delegate), |
532 dispatcher_(NULL) {} | 532 dispatcher_(NULL) {} |
533 | 533 |
534 ViewManagerClientImpl::~ViewManagerClientImpl() { | 534 ViewManagerClientImpl::~ViewManagerClientImpl() { |
535 delegate_->OnViewManagerDisconnected(this); | |
536 while (!nodes_.empty()) { | 535 while (!nodes_.empty()) { |
537 IdToNodeMap::iterator it = nodes_.begin(); | 536 IdToNodeMap::iterator it = nodes_.begin(); |
538 if (OwnsNode(it->second->id())) | 537 if (OwnsNode(it->second->id())) |
539 it->second->Destroy(); | 538 it->second->Destroy(); |
540 else | 539 else |
541 nodes_.erase(it); | 540 nodes_.erase(it); |
542 } | 541 } |
543 while (!views_.empty()) { | 542 while (!views_.empty()) { |
544 IdToViewMap::iterator it = views_.begin(); | 543 IdToViewMap::iterator it = views_.begin(); |
545 if (OwnsView(it->second->id())) | 544 if (OwnsView(it->second->id())) |
546 it->second->Destroy(); | 545 it->second->Destroy(); |
547 else | 546 else |
548 views_.erase(it); | 547 views_.erase(it); |
549 } | 548 } |
| 549 delegate_->OnViewManagerDisconnected(this); |
550 } | 550 } |
551 | 551 |
552 Id ViewManagerClientImpl::CreateNode() { | 552 Id ViewManagerClientImpl::CreateNode() { |
553 DCHECK(connected_); | 553 DCHECK(connected_); |
554 const Id node_id(MakeTransportId(connection_id_, ++next_id_)); | 554 const Id node_id(MakeTransportId(connection_id_, ++next_id_)); |
555 pending_transactions_.push_back(new CreateNodeTransaction(node_id, this)); | 555 pending_transactions_.push_back(new CreateNodeTransaction(node_id, this)); |
556 Sync(); | 556 Sync(); |
557 return node_id; | 557 return node_id; |
558 } | 558 } |
559 | 559 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 | 878 |
879 // static | 879 // static |
880 void ViewManager::ConfigureIncomingConnection( | 880 void ViewManager::ConfigureIncomingConnection( |
881 ApplicationConnection* connection, | 881 ApplicationConnection* connection, |
882 ViewManagerDelegate* delegate) { | 882 ViewManagerDelegate* delegate) { |
883 connection->AddService<ViewManagerClientImpl>(delegate); | 883 connection->AddService<ViewManagerClientImpl>(delegate); |
884 } | 884 } |
885 | 885 |
886 } // namespace view_manager | 886 } // namespace view_manager |
887 } // namespace mojo | 887 } // namespace mojo |
OLD | NEW |