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

Side by Side Diff: headless/lib/browser/types_h.template

Issue 1906493002: headless: Replace headless::Maybe with base::Optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « headless/lib/browser/types_cc.template ('k') | headless/public/util/maybe.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // This file is generated 1 // This file is generated
2 2
3 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 3 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be 4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file. 5 // found in the LICENSE file.
6 6
7 #ifndef HEADLESS_PUBLIC_DOMAINS_TYPES_H_ 7 #ifndef HEADLESS_PUBLIC_DOMAINS_TYPES_H_
8 #define HEADLESS_PUBLIC_DOMAINS_TYPES_H_ 8 #define HEADLESS_PUBLIC_DOMAINS_TYPES_H_
9 9
10 #include "base/optional.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "headless/public/headless_export.h" 12 #include "headless/public/headless_export.h"
12 #include "headless/public/util/error_reporter.h" 13 #include "headless/public/util/error_reporter.h"
13 #include "headless/public/util/maybe.h"
14 14
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 16
17 namespace headless { 17 namespace headless {
18 18
19 // ------------- Forward declarations and typedefs. 19 // ------------- Forward declarations and typedefs.
20 20
21 {% for domain in api.domains %} 21 {% for domain in api.domains %}
22 22
23 namespace {{domain.domain | camelcase_to_hacker_style}} { 23 namespace {{domain.domain | camelcase_to_hacker_style}} {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 class HEADLESS_EXPORT {{type.id}} { 62 class HEADLESS_EXPORT {{type.id}} {
63 public: 63 public:
64 static {{resolve_type(type).pass_type}} Parse(const base::Value& value, ErrorR eporter* errors); 64 static {{resolve_type(type).pass_type}} Parse(const base::Value& value, ErrorR eporter* errors);
65 ~{{type.id}}() { } 65 ~{{type.id}}() { }
66 {% for property in type.properties %} 66 {% for property in type.properties %}
67 67
68 {% if property.description %} 68 {% if property.description %}
69 // {{property.description}} 69 // {{property.description}}
70 {% endif %} 70 {% endif %}
71 {% if property.optional %} 71 {% if property.optional %}
72 bool Has{{property.name | to_title_case}}() { return {{property.name | camelca se_to_hacker_style}}_.IsJust(); } 72 bool Has{{property.name | to_title_case}}() { return !!{{property.name | camel case_to_hacker_style}}_; }
73 {{resolve_type(property).raw_return_type}} Get{{property.name | to_title_case} }() { return {{resolve_type(property).to_raw_return_type % ("%s_.FromJust()" % p roperty.name | camelcase_to_hacker_style)}}; } 73 {{resolve_type(property).raw_return_type}} Get{{property.name | to_title_case} }() { return {{resolve_type(property).to_raw_return_type % ("%s_.value()" % prop erty.name | camelcase_to_hacker_style)}}; }
74 void Set{{property.name | to_title_case}}({{resolve_type(property).pass_type}} value) { {{property.name | camelcase_to_hacker_style}}_ = Just({{resolve_type(p roperty).to_pass_type % 'value'}}); } 74 void Set{{property.name | to_title_case}}({{resolve_type(property).pass_type}} value) { {{property.name | camelcase_to_hacker_style}}_ = {{resolve_type(proper ty).to_pass_type % 'value'}}; }
75 {% else %} 75 {% else %}
76 {{resolve_type(property).raw_return_type}} Get{{property.name | to_title_case} }() { return {{resolve_type(property).to_raw_return_type % ("%s_" % property.nam e | camelcase_to_hacker_style)}}; } 76 {{resolve_type(property).raw_return_type}} Get{{property.name | to_title_case} }() { return {{resolve_type(property).to_raw_return_type % ("%s_" % property.nam e | camelcase_to_hacker_style)}}; }
77 void Set{{property.name | to_title_case}}({{resolve_type(property).pass_type}} value) { {{property.name | camelcase_to_hacker_style}}_ = {{resolve_type(proper ty).to_pass_type % 'value'}}; } 77 void Set{{property.name | to_title_case}}({{resolve_type(property).pass_type}} value) { {{property.name | camelcase_to_hacker_style}}_ = {{resolve_type(proper ty).to_pass_type % 'value'}}; }
78 {% endif %} 78 {% endif %}
79 {% endfor %} 79 {% endfor %}
80 80
81 std::unique_ptr<base::Value> Serialize() const; 81 std::unique_ptr<base::Value> Serialize() const;
82 {{resolve_type(type).pass_type}} Clone() const; 82 {{resolve_type(type).pass_type}} Clone() const;
83 83
84 template<int STATE> 84 template<int STATE>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 static {{type.id}}Builder<0> Builder() { 133 static {{type.id}}Builder<0> Builder() {
134 return {{type.id}}Builder<0>(); 134 return {{type.id}}Builder<0>();
135 } 135 }
136 136
137 private: 137 private:
138 {{type.id}}() { } 138 {{type.id}}() { }
139 139
140 {% for property in type.properties %} 140 {% for property in type.properties %}
141 {% if property.optional %} 141 {% if property.optional %}
142 Maybe<{{resolve_type(property).type}}> {{property.name | camelcase_to_hacker_s tyle}}_; 142 base::Optional<{{resolve_type(property).type}}> {{property.name | camelcase_to _hacker_style}}_;
143 {% else %} 143 {% else %}
144 {{resolve_type(property).type}} {{property.name | camelcase_to_hacker_style}}_ ; 144 {{resolve_type(property).type}} {{property.name | camelcase_to_hacker_style}}_ ;
145 {% endif %} 145 {% endif %}
146 {% endfor %} 146 {% endfor %}
147 147
148 DISALLOW_COPY_AND_ASSIGN({{type.id}}); 148 DISALLOW_COPY_AND_ASSIGN({{type.id}});
149 }; 149 };
150 150
151 {% endfor %} 151 {% endfor %}
152 152
153 } // namespace {{domain.domain | camelcase_to_hacker_style}} 153 } // namespace {{domain.domain | camelcase_to_hacker_style}}
154 {% endfor %} 154 {% endfor %}
155 155
156 } // namespace headless 156 } // namespace headless
157 157
158 #endif // HEADLESS_PUBLIC_DOMAINS_TYPES_H_ 158 #endif // HEADLESS_PUBLIC_DOMAINS_TYPES_H_
OLDNEW
« no previous file with comments | « headless/lib/browser/types_cc.template ('k') | headless/public/util/maybe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698