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

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

Issue 1415493003: mozart: Initial commit of the view manager. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/view_manager/view_state.h ('k') | services/ui/view_manager/view_tree_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/view_manager/view_state.cc
diff --git a/services/ui/view_manager/view_state.cc b/services/ui/view_manager/view_state.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cfccc564cdfe7cbf6e68340639928fce425a55db
--- /dev/null
+++ b/services/ui/view_manager/view_state.cc
@@ -0,0 +1,55 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "services/ui/view_manager/view_state.h"
+#include "services/ui/view_manager/view_tree_state.h"
+
+namespace view_manager {
+
+ViewState::ViewState(mojo::ui::ViewPtr view, uint32_t view_token_value)
+ : view_(view.Pass()),
+ view_token_value_(view_token_value),
+ tree_(nullptr),
+ parent_(nullptr),
+ key_(0),
+ weak_factory_(this) {
+ DCHECK(view_);
+}
+
+ViewState::~ViewState() {}
+
+void ViewState::SetTree(ViewTreeState* tree, uint32_t key) {
+ DCHECK(tree);
+ DCHECK(!parent_); // must be the root
+ if (tree_ != tree) {
+ SetTreeUnchecked(tree);
+ }
+ key_ = key;
+}
+
+void ViewState::SetTreeUnchecked(ViewTreeState* tree) {
+ tree_ = tree;
+ for (const auto& pair : children_) {
+ pair.second->SetTreeUnchecked(tree);
+ }
+}
+
+void ViewState::SetParent(ViewState* parent, uint32_t key) {
+ DCHECK(parent);
+ parent_ = parent;
+ key_ = key;
+ SetTreeUnchecked(parent->tree_);
+}
+
+void ViewState::ResetContainer() {
+ parent_ = nullptr;
+ key_ = 0;
+ SetTreeUnchecked(nullptr);
+}
+
+void ViewState::GetServiceProvider(
+ mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) {}
+
+} // namespace view_manager
« no previous file with comments | « services/ui/view_manager/view_state.h ('k') | services/ui/view_manager/view_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698