Chromium Code Reviews| Index: services/ui/view_manager/view_layout_request.cc |
| diff --git a/services/ui/view_manager/view_layout_request.cc b/services/ui/view_manager/view_layout_request.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..343f1452cdabb1c95dd1c0e4cc218ddfde581e12 |
| --- /dev/null |
| +++ b/services/ui/view_manager/view_layout_request.cc |
| @@ -0,0 +1,33 @@ |
| +// 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_layout_request.h" |
| + |
| +namespace view_manager { |
| + |
| +ViewLayoutRequest::ViewLayoutRequest( |
| + mojo::ui::ViewLayoutParamsPtr layout_params) |
| + : issued(false), |
| + layout_params_(layout_params.Pass()), |
| + was_dispatched_(false) {} |
| + |
| +ViewLayoutRequest::~ViewLayoutRequest() { |
| + if (!was_dispatched_) |
| + DispatchLayoutInfo(nullptr); |
| +} |
| + |
| +void ViewLayoutRequest::AddCallback(const ViewLayoutCallback& callback) { |
| + DCHECK(!was_dispatched_); |
| + callbacks_.emplace_back(callback); |
| +} |
| + |
| +void ViewLayoutRequest::DispatchLayoutInfo(mojo::ui::ViewLayoutInfo* info) { |
| + DCHECK(!was_dispatched_); |
| + was_dispatched_ = true; |
| + for (auto callback : callbacks_) |
|
jamesr
2015/10/27 23:13:10
const auto&, you don't wanna copy the callback eve
jeffbrown
2015/10/28 01:37:29
Done.
|
| + callback.Run(info ? info->Clone() : nullptr); |
| +} |
| + |
| +} // namespace view_manager |