Chromium Code Reviews| 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 : issued(false), | |
| 13 layout_params_(layout_params.Pass()), | |
| 14 was_dispatched_(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 (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.
| |
| 30 callback.Run(info ? info->Clone() : nullptr); | |
| 31 } | |
| 32 | |
| 33 } // namespace view_manager | |
| OLD | NEW |