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

Unified Diff: services/ui/view_manager/view_tree_state.cc

Issue 1679023006: Reify view ownership as a message pipe. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/view_manager/view_tree_state.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/view_manager/view_tree_state.cc
diff --git a/services/ui/view_manager/view_tree_state.cc b/services/ui/view_manager/view_tree_state.cc
index 4a69f2c318d7815e7c64c36b37269ce9c66826d3..1d8f502cf45081349aac27e268985347d05f178d 100644
--- a/services/ui/view_manager/view_tree_state.cc
+++ b/services/ui/view_manager/view_tree_state.cc
@@ -4,41 +4,56 @@
#include "services/ui/view_manager/view_tree_state.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
+#include "services/ui/view_manager/view_registry.h"
+#include "services/ui/view_manager/view_state.h"
+#include "services/ui/view_manager/view_stub.h"
+#include "services/ui/view_manager/view_tree_host_impl.h"
namespace view_manager {
-ViewTreeState::ViewTreeState(mojo::ui::ViewTreePtr view_tree,
- mojo::ui::ViewTreeTokenPtr view_tree_token,
- const std::string& label)
+ViewTreeState::ViewTreeState(
+ ViewRegistry* registry,
+ mojo::ui::ViewTreePtr view_tree,
+ mojo::ui::ViewTreeTokenPtr view_tree_token,
+ mojo::InterfaceRequest<mojo::ui::ViewTreeHost> view_tree_host_request,
+ const std::string& label)
: view_tree_(view_tree.Pass()),
view_tree_token_(view_tree_token.Pass()),
label_(label),
+ impl_(new ViewTreeHostImpl(registry, this)),
+ host_binding_(impl_.get(), view_tree_host_request.Pass()),
weak_factory_(this) {
DCHECK(view_tree_);
DCHECK(view_tree_token_);
+
+ view_tree_.set_connection_error_handler(
+ base::Bind(&ViewRegistry::OnViewTreeDied, base::Unretained(registry),
+ base::Unretained(this), "ViewTree connection closed"));
+ host_binding_.set_connection_error_handler(
+ base::Bind(&ViewRegistry::OnViewTreeDied, base::Unretained(registry),
+ base::Unretained(this), "ViewTreeHost connection closed"));
}
ViewTreeState::~ViewTreeState() {}
-void ViewTreeState::SetRoot(ViewState* root, uint32_t key) {
+void ViewTreeState::LinkRoot(uint32_t key, std::unique_ptr<ViewStub> root) {
+ DCHECK(!root_);
DCHECK(root);
- if (root_ != root) {
- ResetRoot();
- root->SetTree(this, key);
- root_ = root;
- }
+ DCHECK(!root->is_linked());
+ root->SetTree(this, key);
+ root_ = std::move(root);
}
-void ViewTreeState::ResetRoot() {
- if (root_) {
- root_->ResetContainer();
- }
- root_ = nullptr;
+std::unique_ptr<ViewStub> ViewTreeState::UnlinkRoot() {
+ DCHECK(root_);
+ root_->Unlink();
+ return std::move(root_);
}
-const std::string& ViewTreeState::FormattedLabel() {
+const std::string& ViewTreeState::FormattedLabel() const {
if (formatted_label_cache_.empty()) {
formatted_label_cache_ =
label_.empty() ? base::StringPrintf("<%d>", view_tree_token_->value)
« no previous file with comments | « services/ui/view_manager/view_tree_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698