Chromium Code Reviews| 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 |
| index cfccc564cdfe7cbf6e68340639928fce425a55db..f106bec3c3c6860ce5126654cc4d691948791c13 100644 |
| --- a/services/ui/view_manager/view_state.cc |
| +++ b/services/ui/view_manager/view_state.cc |
| @@ -2,20 +2,22 @@ |
| // 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 "base/logging.h" |
| #include "services/ui/view_manager/view_tree_state.h" |
| namespace view_manager { |
| -ViewState::ViewState(mojo::ui::ViewPtr view, uint32_t view_token_value) |
| +ViewState::ViewState(mojo::ui::ViewPtr view, |
| + mojo::ui::ViewTokenPtr view_token, |
| + const std::string& label) |
| : view_(view.Pass()), |
| - view_token_value_(view_token_value), |
| - tree_(nullptr), |
| - parent_(nullptr), |
| - key_(0), |
| + view_token_(view_token.Pass()), |
| + label_(label), |
| weak_factory_(this) { |
| DCHECK(view_); |
| + DCHECK(view_token_); |
| } |
| ViewState::~ViewState() {} |
| @@ -49,7 +51,32 @@ void ViewState::ResetContainer() { |
| SetTreeUnchecked(nullptr); |
| } |
| -void ViewState::GetServiceProvider( |
| - mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) {} |
| +mojo::ui::ViewLayoutInfoPtr ViewState::CreateLayoutInfo() { |
|
abarth
2016/01/10 01:42:55
The difference between ViewLayoutInfo and ViewLayo
jeffbrown
2016/01/26 05:59:13
Agreed. The whole layout protocol is going to be
|
| + if (!layout_result_ || !scene_token_) |
| + return nullptr; |
| + |
| + auto info = mojo::ui::ViewLayoutInfo::New(); |
| + info->size = layout_result_->size.Clone(); |
| + info->scene_token = scene_token_.Clone(); |
| + return info; |
| +} |
| + |
| +std::string ViewState::FormattedLabel() { |
| + if (formatted_label_cache_.empty()) { |
| + std::ostringstream s; |
| + s << "<" << view_token_->value; |
| + if (!label_.empty()) |
| + s << ":" << label_; |
| + s << ">"; |
| + formatted_label_cache_ = s.str(); |
|
abarth
2016/01/10 01:42:55
There's base::StringPrintf if you'd like something
jeffbrown
2016/01/26 05:59:13
Done.
|
| + } |
| + return formatted_label_cache_; |
| +} |
| + |
| +std::ostream& operator<<(std::ostream& os, ViewState* view_state) { |
| + if (!view_state) |
| + return os << "null"; |
| + return os << view_state->FormattedLabel(); |
| +} |
| } // namespace view_manager |