| OLD | NEW |
| 1 // This file is generated | 1 // This file is generated |
| 2 | 2 |
| 3 // Copyright 2016 The Chromium Authors. All rights reserved. | 3 // Copyright 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 #include "headless/public/devtools/domains/{{domain.domain | camelcase_to_hacker
_style}}.h" | 7 #include "headless/public/devtools/domains/{{domain.domain | camelcase_to_hacker
_style}}.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 {# Generate response handlers for commands that need them. #} | 96 {# Generate response handlers for commands that need them. #} |
| 97 {% for command in domain.commands %} | 97 {% for command in domain.commands %} |
| 98 {% if not "returns" in command %}{% continue %}{% endif %} | 98 {% if not "returns" in command %}{% continue %}{% endif %} |
| 99 {% set method_name = command.name | to_title_case %} | 99 {% set method_name = command.name | to_title_case %} |
| 100 | 100 |
| 101 // static | 101 // static |
| 102 void Domain::Handle{{method_name}}Response(base::Callback<void(std::unique_ptr<{
{method_name}}Result>)> callback, const base::Value& response) { | 102 void Domain::Handle{{method_name}}Response(base::Callback<void(std::unique_ptr<{
{method_name}}Result>)> callback, const base::Value& response) { |
| 103 if (callback.is_null()) | 103 if (callback.is_null()) |
| 104 return; | 104 return; |
| 105 // This is an error response. |
| 106 if (response.IsType(base::Value::TYPE_NULL)) { |
| 107 callback.Run(nullptr); |
| 108 return; |
| 109 } |
| 105 ErrorReporter errors; | 110 ErrorReporter errors; |
| 106 std::unique_ptr<{{method_name}}Result> result = {{method_name}}Result::Parse(r
esponse, &errors); | 111 std::unique_ptr<{{method_name}}Result> result = {{method_name}}Result::Parse(r
esponse, &errors); |
| 107 DCHECK(!errors.HasErrors()); | 112 DCHECK(!errors.HasErrors()); |
| 108 callback.Run(std::move(result)); | 113 callback.Run(std::move(result)); |
| 109 } | 114 } |
| 110 {% endfor %} | 115 {% endfor %} |
| 111 {% if "events" in domain %} | 116 {% if "events" in domain %} |
| 112 {% for event in domain.events %} | 117 {% for event in domain.events %} |
| 113 | 118 |
| 114 {# Generate dispatchers which call registered observers for an event. #} | 119 {# Generate dispatchers which call registered observers for an event. #} |
| (...skipping 26 matching lines...) Expand all Loading... |
| 141 } | 146 } |
| 142 | 147 |
| 143 void ExperimentalDomain::RemoveObserver(ExperimentalObserver* observer) { | 148 void ExperimentalDomain::RemoveObserver(ExperimentalObserver* observer) { |
| 144 observers_.RemoveObserver(observer); | 149 observers_.RemoveObserver(observer); |
| 145 } | 150 } |
| 146 {% endif %} | 151 {% endif %} |
| 147 | 152 |
| 148 } // namespace {{domain.domain | camelcase_to_hacker_style}} | 153 } // namespace {{domain.domain | camelcase_to_hacker_style}} |
| 149 | 154 |
| 150 } // namespace headless | 155 } // namespace headless |
| OLD | NEW |