| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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. | 105 // This is an error response. |
| 106 if (response.IsType(base::Value::TYPE_NULL)) { | 106 if (response.IsType(base::Value::Type::NONE)) { |
| 107 callback.Run(nullptr); | 107 callback.Run(nullptr); |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 ErrorReporter errors; | 110 ErrorReporter errors; |
| 111 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); |
| 112 DCHECK(!errors.HasErrors()); | 112 DCHECK(!errors.HasErrors()); |
| 113 callback.Run(std::move(result)); | 113 callback.Run(std::move(result)); |
| 114 } | 114 } |
| 115 {% endfor %} | 115 {% endfor %} |
| 116 {% if "events" in domain %} | 116 {% if "events" in domain %} |
| (...skipping 29 matching lines...) Expand all Loading... |
| 146 } | 146 } |
| 147 | 147 |
| 148 void ExperimentalDomain::RemoveObserver(ExperimentalObserver* observer) { | 148 void ExperimentalDomain::RemoveObserver(ExperimentalObserver* observer) { |
| 149 observers_.RemoveObserver(observer); | 149 observers_.RemoveObserver(observer); |
| 150 } | 150 } |
| 151 {% endif %} | 151 {% endif %} |
| 152 | 152 |
| 153 } // namespace {{domain.domain | camelcase_to_hacker_style}} | 153 } // namespace {{domain.domain | camelcase_to_hacker_style}} |
| 154 | 154 |
| 155 } // namespace headless | 155 } // namespace headless |
| OLD | NEW |