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

Side by Side 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, 1 month 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 unified diff | Download patch
OLDNEW
(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 #ifndef SERVICES_UI_VIEW_MANAGER_VIEW_LAYOUT_REQUEST_H_
6 #define SERVICES_UI_VIEW_MANAGER_VIEW_LAYOUT_REQUEST_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "mojo/services/ui/views/interfaces/layouts.mojom.h"
14
15 namespace view_manager {
16
17 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.
18
19 // Describes a pending layout request for a view.
20 class ViewLayoutRequest {
21 public:
22 ViewLayoutRequest(mojo::ui::ViewLayoutParamsPtr layout_params);
jamesr 2015/10/27 23:13:10 explicit
jeffbrown 2015/10/28 01:37:29 Done.
23
24 // 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
25 // called.
26 ~ViewLayoutRequest();
27
28 // Gets the layout parameters for this request.
29 // Does not confer ownership.
30 mojo::ui::ViewLayoutParams* layout_params() { return layout_params_.get(); }
31
32 // Gets the layout parameters for this request and takes ownership.
33 mojo::ui::ViewLayoutParamsPtr TakeLayoutParams() {
34 return layout_params_.Pass();
35 }
36
37 // Adds a callback to this layout request.
38 // Must be called before dispatching.
39 void AddCallback(const ViewLayoutCallback& callback);
40
41 // Returns true if the request has callbacks.
42 bool has_callbacks() { return !callbacks_.empty(); }
43
44 // Sends the layout information to each client.
45 // Must be invoked exactly once before destroying the request to prevent
46 // dangling callbacks.
47 void DispatchLayoutInfo(mojo::ui::ViewLayoutInfo* info);
48
49 // True if the request has been issued to the view.
50 // False if it is still pending in the queue.
51 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
52
53 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
54 std::vector<ViewLayoutCallback> callbacks_;
55 bool was_dispatched_;
56
57 DISALLOW_COPY_AND_ASSIGN(ViewLayoutRequest);
jamesr 2015/10/27 23:13:10 and this only makes sense in a private section
58 };
59
60 } // namespace view_manager
61
62 #endif // SERVICES_UI_VIEW_MANAGER_VIEW_LAYOUT_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698