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

Side by Side Diff: components/mus/public/cpp/lib/view_tree_client_impl.cc

Issue 1390353007: Adds MUSViewsInit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix windows Created 5 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 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 "components/mus/public/cpp/lib/view_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/view_tree_client_impl.h"
6 6
7 #include "components/mus/public/cpp/lib/view_private.h" 7 #include "components/mus/public/cpp/lib/view_private.h"
8 #include "components/mus/public/cpp/util.h" 8 #include "components/mus/public/cpp/util.h"
9 #include "components/mus/public/cpp/view_observer.h" 9 #include "components/mus/public/cpp/view_observer.h"
10 #include "components/mus/public/cpp/view_tree_connection.h" 10 #include "components/mus/public/cpp/view_tree_connection.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 client, !parents.empty() ? parents.back() : NULL, views[i]); 63 client, !parents.empty() ? parents.back() : NULL, views[i]);
64 if (!last_view) 64 if (!last_view)
65 root = view; 65 root = view;
66 last_view = view; 66 last_view = view;
67 } 67 }
68 return root; 68 return root;
69 } 69 }
70 70
71 ViewTreeConnection* ViewTreeConnection::Create( 71 ViewTreeConnection* ViewTreeConnection::Create(
72 ViewTreeDelegate* delegate, 72 ViewTreeDelegate* delegate,
73 mojo::InterfaceRequest<mojo::ViewTreeClient> request) { 73 mojo::InterfaceRequest<mojo::ViewTreeClient> request,
74 return new ViewTreeClientImpl(delegate, request.Pass()); 74 CreateType create_type) {
75 ViewTreeClientImpl* client = new ViewTreeClientImpl(delegate, request.Pass());
76 if (create_type == CreateType::WAIT_FOR_EMBED)
77 client->WaitForEmbed();
78 return client;
75 } 79 }
76 80
77 ViewTreeClientImpl::ViewTreeClientImpl( 81 ViewTreeClientImpl::ViewTreeClientImpl(
78 ViewTreeDelegate* delegate, 82 ViewTreeDelegate* delegate,
79 mojo::InterfaceRequest<mojo::ViewTreeClient> request) 83 mojo::InterfaceRequest<mojo::ViewTreeClient> request)
80 : connection_id_(0), 84 : connection_id_(0),
81 next_id_(1), 85 next_id_(1),
82 delegate_(delegate), 86 delegate_(delegate),
83 root_(nullptr), 87 root_(nullptr),
84 capture_view_(nullptr), 88 capture_view_(nullptr),
(...skipping 20 matching lines...) Expand all
105 // Delete the non-owned views last. In the typical case these are roots. The 109 // Delete the non-owned views last. In the typical case these are roots. The
106 // exception is the window manager and embed roots, which may know about 110 // exception is the window manager and embed roots, which may know about
107 // other random views that it doesn't own. 111 // other random views that it doesn't own.
108 // NOTE: we manually delete as we're a friend. 112 // NOTE: we manually delete as we're a friend.
109 for (size_t i = 0; i < non_owned.size(); ++i) 113 for (size_t i = 0; i < non_owned.size(); ++i)
110 delete non_owned[i]; 114 delete non_owned[i];
111 115
112 delegate_->OnConnectionLost(this); 116 delegate_->OnConnectionLost(this);
113 } 117 }
114 118
119 void ViewTreeClientImpl::WaitForEmbed() {
120 DCHECK(!root_);
121 // OnEmbed() is the first function called.
122 binding_.WaitForIncomingMethodCall();
123 // TODO(sky): deal with pipe being closed before we get OnEmbed().
124 }
125
115 void ViewTreeClientImpl::DestroyView(Id view_id) { 126 void ViewTreeClientImpl::DestroyView(Id view_id) {
116 DCHECK(tree_); 127 DCHECK(tree_);
117 tree_->DeleteView(view_id, ActionCompletedCallback()); 128 tree_->DeleteView(view_id, ActionCompletedCallback());
118 } 129 }
119 130
120 void ViewTreeClientImpl::AddChild(Id child_id, Id parent_id) { 131 void ViewTreeClientImpl::AddChild(Id child_id, Id parent_id) {
121 DCHECK(tree_); 132 DCHECK(tree_);
122 tree_->AddView(parent_id, child_id, ActionCompletedCallback()); 133 tree_->AddView(parent_id, child_id, ActionCompletedCallback());
123 } 134 }
124 135
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 void ViewTreeClientImpl::OnActionCompleted(bool success) { 440 void ViewTreeClientImpl::OnActionCompleted(bool success) {
430 if (!change_acked_callback_.is_null()) 441 if (!change_acked_callback_.is_null())
431 change_acked_callback_.Run(); 442 change_acked_callback_.Run();
432 } 443 }
433 444
434 mojo::Callback<void(bool)> ViewTreeClientImpl::ActionCompletedCallback() { 445 mojo::Callback<void(bool)> ViewTreeClientImpl::ActionCompletedCallback() {
435 return [this](bool success) { OnActionCompleted(success); }; 446 return [this](bool success) { OnActionCompleted(success); };
436 } 447 }
437 448
438 } // namespace mus 449 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/view_tree_client_impl.h ('k') | components/mus/public/cpp/lib/view_tree_host_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698