| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/view_manager/view_layout_request.h" |
| 6 |
| 5 #include "base/logging.h" | 7 #include "base/logging.h" |
| 6 #include "services/ui/view_manager/view_layout_request.h" | |
| 7 | 8 |
| 8 namespace view_manager { | 9 namespace view_manager { |
| 9 | 10 |
| 10 ViewLayoutRequest::ViewLayoutRequest( | 11 ViewLayoutRequest::ViewLayoutRequest( |
| 11 mojo::ui::ViewLayoutParamsPtr layout_params) | 12 mojo::ui::ViewLayoutParamsPtr layout_params) |
| 12 : layout_params_(layout_params.Pass()), | 13 : layout_params_(layout_params.Pass()), |
| 13 was_dispatched_(false), | 14 was_dispatched_(false), |
| 14 issued_(false) {} | 15 issued_(false) {} |
| 15 | 16 |
| 16 ViewLayoutRequest::~ViewLayoutRequest() { | 17 ViewLayoutRequest::~ViewLayoutRequest() { |
| 17 if (!was_dispatched_) | 18 if (!was_dispatched_) |
| 18 DispatchLayoutInfo(nullptr); | 19 DispatchLayoutInfo(nullptr); |
| 19 } | 20 } |
| 20 | 21 |
| 21 void ViewLayoutRequest::AddCallback(const ViewLayoutCallback& callback) { | 22 void ViewLayoutRequest::AddCallback(const ViewLayoutCallback& callback) { |
| 22 DCHECK(!was_dispatched_); | 23 DCHECK(!was_dispatched_); |
| 23 callbacks_.emplace_back(callback); | 24 callbacks_.emplace_back(callback); |
| 24 } | 25 } |
| 25 | 26 |
| 26 void ViewLayoutRequest::DispatchLayoutInfo(mojo::ui::ViewLayoutInfo* info) { | 27 void ViewLayoutRequest::DispatchLayoutInfo(mojo::ui::ViewLayoutInfoPtr info) { |
| 27 DCHECK(!was_dispatched_); | 28 DCHECK(!was_dispatched_); |
| 28 was_dispatched_ = true; | 29 was_dispatched_ = true; |
| 29 for (const auto& callback : callbacks_) | 30 for (const auto& callback : callbacks_) |
| 30 callback.Run(info ? info->Clone() : nullptr); | 31 callback.Run(info ? info.Clone() : nullptr); |
| 31 } | 32 } |
| 32 | 33 |
| 33 } // namespace view_manager | 34 } // namespace view_manager |
| OLD | NEW |