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