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

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: applied review comments 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
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..473e0c3a89172bcfc3ede060570764d05e74f11a
--- /dev/null
+++ b/services/ui/view_manager/view_layout_request.h
@@ -0,0 +1,62 @@
+// 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 {
+
+typedef base::Callback<void(mojo::ui::ViewLayoutInfoPtr)> ViewLayoutCallback;
jamesr 2015/10/27 23:13:10 prefer 'using' for this sort of thing, it looks sl
jeffbrown 2015/10/28 01:37:29 Done.
+
+// Describes a pending layout request for a view.
+class ViewLayoutRequest {
+ public:
+ ViewLayoutRequest(mojo::ui::ViewLayoutParamsPtr layout_params);
jamesr 2015/10/27 23:13:10 explicit
jeffbrown 2015/10/28 01:37:29 Done.
+
+ // Dispatches null layout info automatically if DispatchLayoutInfo was not
jamesr 2015/10/27 23:13:10 hmm, side-effecty destructors on types that also d
jeffbrown 2015/10/28 01:37:29 Agreed. The side-effect could go at the point whe
+ // 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;
jamesr 2015/10/27 23:13:10 private, no public members on classes (add a gette
jeffbrown 2015/10/28 01:37:29 Got it. Skipping this one since this code is doom
+
+ mojo::ui::ViewLayoutParamsPtr layout_params_;
jamesr 2015/10/27 23:13:10 trailing _ in particular should never be public
jeffbrown 2015/10/28 01:37:29 Somewhere along the way I dropped the private: lin
+ std::vector<ViewLayoutCallback> callbacks_;
+ bool was_dispatched_;
+
+ DISALLOW_COPY_AND_ASSIGN(ViewLayoutRequest);
jamesr 2015/10/27 23:13:10 and this only makes sense in a private section
+};
+
+} // namespace view_manager
+
+#endif // SERVICES_UI_VIEW_MANAGER_VIEW_LAYOUT_REQUEST_H_

Powered by Google App Engine
This is Rietveld 408576698