Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Unified Diff: services/ui/view_manager/view_layout_request.h

Issue 1415493003: mozart: Initial commit of the view manager. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/view_manager/view_host_impl.cc ('k') | services/ui/view_manager/view_layout_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/view_manager/view_layout_request.h
diff --git a/services/ui/view_manager/view_layout_request.h b/services/ui/view_manager/view_layout_request.h
new file mode 100644
index 0000000000000000000000000000000000000000..8091d2fce621fa8894e033f524f9a259f413698f
--- /dev/null
+++ b/services/ui/view_manager/view_layout_request.h
@@ -0,0 +1,65 @@
+// 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.
+
+#ifndef SERVICES_UI_VIEW_MANAGER_VIEW_LAYOUT_REQUEST_H_
+#define SERVICES_UI_VIEW_MANAGER_VIEW_LAYOUT_REQUEST_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "mojo/services/ui/views/interfaces/layouts.mojom.h"
+
+namespace view_manager {
+
+using ViewLayoutCallback = base::Callback<void(mojo::ui::ViewLayoutInfoPtr)>;
+
+// Describes a pending layout request for a view.
+class ViewLayoutRequest {
+ public:
+ explicit ViewLayoutRequest(mojo::ui::ViewLayoutParamsPtr layout_params);
+
+ // Dispatches null layout info automatically if DispatchLayoutInfo was not
+ // called.
+ ~ViewLayoutRequest();
+
+ // Gets the layout parameters for this request.
+ // Does not confer ownership.
+ mojo::ui::ViewLayoutParams* layout_params() { return layout_params_.get(); }
+
+ // Gets the layout parameters for this request and takes ownership.
+ mojo::ui::ViewLayoutParamsPtr TakeLayoutParams() {
+ return layout_params_.Pass();
+ }
+
+ // Adds a callback to this layout request.
+ // Must be called before dispatching.
+ void AddCallback(const ViewLayoutCallback& callback);
+
+ // Returns true if the request has callbacks.
+ bool has_callbacks() { return !callbacks_.empty(); }
+
+ // Sends the layout information to each client.
+ // Must be invoked exactly once before destroying the request to prevent
+ // dangling callbacks.
+ void DispatchLayoutInfo(mojo::ui::ViewLayoutInfo* info);
+
+ // True if the request has been issued to the view.
+ // False if it is still pending in the queue.
+ bool issued() const { return issued_; }
+ void set_issued(bool value) { issued_ = value; }
+
+ private:
+ mojo::ui::ViewLayoutParamsPtr layout_params_;
+ std::vector<ViewLayoutCallback> callbacks_;
+ bool was_dispatched_;
+ bool issued_;
+
+ DISALLOW_COPY_AND_ASSIGN(ViewLayoutRequest);
+};
+
+} // namespace view_manager
+
+#endif // SERVICES_UI_VIEW_MANAGER_VIEW_LAYOUT_REQUEST_H_
« no previous file with comments | « services/ui/view_manager/view_host_impl.cc ('k') | services/ui/view_manager/view_layout_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698