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

Side by Side Diff: mojo/public/cpp/bindings/tests/rect_blink.h

Issue 1821073002: Mojo bindings: Fix typemap includes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "mojo/public/interfaces/bindings/tests/rect.mojom.h"
10 9
11 namespace mojo { 10 namespace mojo {
12 namespace test { 11 namespace test {
13 12
14 // An implementation of a hypothetical Rect type specifically for consumers in 13 // An implementation of a hypothetical Rect type specifically for consumers in
15 // in Blink. Unlike the Chromium variant (see rect_chromium.h) this does not 14 // in Blink. Unlike the Chromium variant (see rect_chromium.h) this does not
16 // support negative origin coordinates and is not copyable. 15 // support negative origin coordinates and is not copyable.
17 class RectBlink { 16 class RectBlink {
18 public: 17 public:
19 RectBlink() {} 18 RectBlink() {}
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 int computeArea() const { return width_ * height_; } 52 int computeArea() const { return width_ * height_; }
54 53
55 private: 54 private:
56 int x_ = 0; 55 int x_ = 0;
57 int y_ = 0; 56 int y_ = 0;
58 int width_ = 0; 57 int width_ = 0;
59 int height_ = 0; 58 int height_ = 0;
60 }; 59 };
61 60
62 } // namespace test 61 } // namespace test
63
64 template <>
65 struct StructTraits<test::Rect, test::RectBlink> {
66 static int x(const test::RectBlink& r) { return r.x(); }
67 static int y(const test::RectBlink& r) { return r.y(); }
68 static int width(const test::RectBlink& r) { return r.width(); }
69 static int height(const test::RectBlink& r) { return r.height(); }
70
71 static bool Read(test::Rect::Reader r, test::RectBlink* out) {
72 if (r.x() < 0 || r.y() < 0 || r.width() < 0 || r.height() < 0) {
73 return false;
74 }
75 out->setX(r.x());
76 out->setY(r.y());
77 out->setWidth(r.width());
78 out->setHeight(r.height());
79 return true;
80 }
81 };
82
83 } // namespace mojo 62 } // namespace mojo
84 63
85 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_ 64 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_RECT_BLINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698