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

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc

Issue 372273004: Shutdown cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 public: 90 public:
91 explicit RootObserver(Node* root) : root_(root) {} 91 explicit RootObserver(Node* root) : root_(root) {}
92 virtual ~RootObserver() {} 92 virtual ~RootObserver() {}
93 93
94 private: 94 private:
95 // Overridden from NodeObserver: 95 // Overridden from NodeObserver:
96 virtual void OnNodeDestroyed(Node* node) OVERRIDE { 96 virtual void OnNodeDestroyed(Node* node) OVERRIDE {
97 DCHECK_EQ(node, root_); 97 DCHECK_EQ(node, root_);
98 static_cast<ViewManagerClientImpl*>( 98 static_cast<ViewManagerClientImpl*>(
99 NodePrivate(root_).view_manager())->RemoveRoot(root_); 99 NodePrivate(root_).view_manager())->RemoveRoot(root_);
100 node->RemoveObserver(this);
100 delete this; 101 delete this;
101 } 102 }
102 103
103 Node* root_; 104 Node* root_;
104 105
105 DISALLOW_COPY_AND_ASSIGN(RootObserver); 106 DISALLOW_COPY_AND_ASSIGN(RootObserver);
106 }; 107 };
107 108
108 class ViewManagerTransaction { 109 class ViewManagerTransaction {
109 public: 110 public:
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 ViewManagerClientImpl::ViewManagerClientImpl(ApplicationConnection* connection, 529 ViewManagerClientImpl::ViewManagerClientImpl(ApplicationConnection* connection,
529 ViewManagerDelegate* delegate) 530 ViewManagerDelegate* delegate)
530 : connected_(false), 531 : connected_(false),
531 connection_id_(0), 532 connection_id_(0),
532 next_id_(1), 533 next_id_(1),
533 next_server_change_id_(0), 534 next_server_change_id_(0),
534 delegate_(delegate), 535 delegate_(delegate),
535 dispatcher_(NULL) {} 536 dispatcher_(NULL) {}
536 537
537 ViewManagerClientImpl::~ViewManagerClientImpl() { 538 ViewManagerClientImpl::~ViewManagerClientImpl() {
539 delegate_->OnViewManagerDisconnected(this);
538 while (!nodes_.empty()) { 540 while (!nodes_.empty()) {
539 IdToNodeMap::iterator it = nodes_.begin(); 541 IdToNodeMap::iterator it = nodes_.begin();
540 if (OwnsNode(it->second->id())) 542 if (OwnsNode(it->second->id()))
541 it->second->Destroy(); 543 it->second->Destroy();
542 else 544 else
543 nodes_.erase(it); 545 nodes_.erase(it);
544 } 546 }
545 while (!views_.empty()) { 547 while (!views_.empty()) {
546 IdToViewMap::iterator it = views_.begin(); 548 IdToViewMap::iterator it = views_.begin();
547 if (OwnsView(it->second->id())) 549 if (OwnsView(it->second->id()))
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 898
897 // static 899 // static
898 void ViewManager::ConfigureIncomingConnection( 900 void ViewManager::ConfigureIncomingConnection(
899 ApplicationConnection* connection, 901 ApplicationConnection* connection,
900 ViewManagerDelegate* delegate) { 902 ViewManagerDelegate* delegate) {
901 connection->AddService<ViewManagerClientImpl>(delegate); 903 connection->AddService<ViewManagerClientImpl>(delegate);
902 } 904 }
903 905
904 } // namespace view_manager 906 } // namespace view_manager
905 } // namespace mojo 907 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698