| OLD | NEW |
| 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 #include "platform/inspector_protocol/{{class_name}}.h" | 7 #include "platform/inspector_protocol/{{class_name}}.h" |
| 8 | 8 |
| 9 #include "platform/inspector_protocol/Collections.h" | 9 #include "platform/inspector_protocol/Collections.h" |
| 10 #include "platform/inspector_protocol/FrontendChannel.h" | 10 #include "platform/inspector_protocol/FrontendChannel.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return weak; | 70 return weak; |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual void dispatch(const String16& message); | 73 virtual void dispatch(const String16& message); |
| 74 virtual void reportProtocolError(int callId, CommonErrorCode, const String16
& errorMessage, ErrorSupport* errors) const; | 74 virtual void reportProtocolError(int callId, CommonErrorCode, const String16
& errorMessage, ErrorSupport* errors) const; |
| 75 using Dispatcher::reportProtocolError; | 75 using Dispatcher::reportProtocolError; |
| 76 | 76 |
| 77 void sendResponse(int callId, const ErrorString& invocationError, ErrorSuppo
rt* errors, std::unique_ptr<protocol::DictionaryValue> result); | 77 void sendResponse(int callId, const ErrorString& invocationError, ErrorSuppo
rt* errors, std::unique_ptr<protocol::DictionaryValue> result); |
| 78 | 78 |
| 79 {% for domain in api.domains %} | 79 {% for domain in api.domains %} |
| 80 virtual void registerAgent(blink::protocol::Backend::{{domain.domain}}* agen
t) { DCHECK(!m_{{domain.domain | lower}}Agent); m_{{domain.domain | lower}}Agent
= agent; } | 80 virtual void registerAgent(blink::protocol::{{domain.domain}}::Backend* agen
t) { DCHECK(!m_{{domain.domain | lower}}Agent); m_{{domain.domain | lower}}Agent
= agent; } |
| 81 {% endfor %} | 81 {% endfor %} |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 friend class DispatcherCallbackBase; | 84 friend class DispatcherCallbackBase; |
| 85 friend class DispatcherImplWeakPtr; | 85 friend class DispatcherImplWeakPtr; |
| 86 using CallHandler = void (DispatcherImpl::*)(int callId, std::unique_ptr<Dic
tionaryValue> messageObject, ErrorSupport* errors); | 86 using CallHandler = void (DispatcherImpl::*)(int callId, std::unique_ptr<Dic
tionaryValue> messageObject, ErrorSupport* errors); |
| 87 using DispatchMap = protocol::HashMap<String16, CallHandler>; | 87 using DispatchMap = protocol::HashMap<String16, CallHandler>; |
| 88 | 88 |
| 89 {% for domain in api.domains %} | 89 {% for domain in api.domains %} |
| 90 {% for command in domain.commands %} | 90 {% for command in domain.commands %} |
| 91 {% if "redirect" in command %}{% continue %}{% endif %} | 91 {% if "redirect" in command %}{% continue %}{% endif %} |
| 92 {% if "handlers" in command and not ("renderer" in command["handlers"]) %}{%
continue %}{% endif %} | 92 {% if "handlers" in command and not ("renderer" in command["handlers"]) %}{%
continue %}{% endif %} |
| 93 void {{domain.domain}}_{{command.name}}(int callId, std::unique_ptr<Dictiona
ryValue> requestMessageObject, ErrorSupport*); | 93 void {{domain.domain}}_{{command.name}}(int callId, std::unique_ptr<Dictiona
ryValue> requestMessageObject, ErrorSupport*); |
| 94 {% endfor %} | 94 {% endfor %} |
| 95 {% endfor %} | 95 {% endfor %} |
| 96 | 96 |
| 97 FrontendChannel* m_frontendChannel; | 97 FrontendChannel* m_frontendChannel; |
| 98 | 98 |
| 99 {% for domain in api.domains %} | 99 {% for domain in api.domains %} |
| 100 Backend::{{domain.domain}}* m_{{domain.domain | lower}}Agent; | 100 {{domain.domain}}::Backend* m_{{domain.domain | lower}}Agent; |
| 101 {% endfor %} | 101 {% endfor %} |
| 102 | 102 |
| 103 void sendResponse(int callId, ErrorString invocationError, std::unique_ptr<p
rotocol::DictionaryValue> result) | 103 void sendResponse(int callId, ErrorString invocationError, std::unique_ptr<p
rotocol::DictionaryValue> result) |
| 104 { | 104 { |
| 105 sendResponse(callId, invocationError, nullptr, std::move(result)); | 105 sendResponse(callId, invocationError, nullptr, std::move(result)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void sendResponse(int callId, ErrorString invocationError) | 108 void sendResponse(int callId, ErrorString invocationError) |
| 109 { | 109 { |
| 110 sendResponse(callId, invocationError, nullptr, DictionaryValue::create()
); | 110 sendResponse(callId, invocationError, nullptr, DictionaryValue::create()
); |
| 111 } | 111 } |
| 112 | 112 |
| 113 static const char kInvalidRequest[]; | 113 static const char kInvalidRequest[]; |
| 114 | 114 |
| 115 DispatchMap m_dispatchMap; | 115 DispatchMap m_dispatchMap; |
| 116 protocol::Vector<int> m_commonErrors; | 116 protocol::Vector<int> m_commonErrors; |
| 117 protocol::HashSet<DispatcherImplWeakPtr*> m_weakPtrs; | 117 protocol::HashSet<DispatcherImplWeakPtr*> m_weakPtrs; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 class PLATFORM_EXPORT DispatcherCallbackBase : public protocol::Backend::Callbac
kBase { | 120 class PLATFORM_EXPORT DispatcherCallbackBase : public protocol::BackendCallback
{ |
| 121 public: | 121 public: |
| 122 DispatcherCallbackBase(std::unique_ptr<DispatcherImplWeakPtr> backendImpl, i
nt callId) | 122 DispatcherCallbackBase(std::unique_ptr<DispatcherImplWeakPtr> backendImpl, i
nt callId) |
| 123 : m_backendImpl(std::move(backendImpl)), m_callId(callId) { } | 123 : m_backendImpl(std::move(backendImpl)), m_callId(callId) { } |
| 124 virtual ~DispatcherCallbackBase() { } | 124 virtual ~DispatcherCallbackBase() { } |
| 125 void dispose() { m_backendImpl = nullptr; } | 125 void dispose() { m_backendImpl = nullptr; } |
| 126 | 126 |
| 127 protected: | 127 protected: |
| 128 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMessage,
const ErrorString& invocationError) | 128 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMessage,
const ErrorString& invocationError) |
| 129 { | 129 { |
| 130 if (!m_backendImpl->get()) | 130 if (!m_backendImpl->get()) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 146 | 146 |
| 147 const char DispatcherImpl::kInvalidRequest[] = "Invalid request"; | 147 const char DispatcherImpl::kInvalidRequest[] = "Invalid request"; |
| 148 | 148 |
| 149 {% for domain in api.domains %} | 149 {% for domain in api.domains %} |
| 150 {% for command in domain.commands %} | 150 {% for command in domain.commands %} |
| 151 {% if "redirect" in command %}{% continue %}{% endif %} | 151 {% if "redirect" in command %}{% continue %}{% endif %} |
| 152 {% if "handlers" in command and not ("renderer" in command["handlers"]) %}{%
continue %}{% endif %} | 152 {% if "handlers" in command and not ("renderer" in command["handlers"]) %}{%
continue %}{% endif %} |
| 153 | 153 |
| 154 {% if "async" in command %} | 154 {% if "async" in command %} |
| 155 | 155 |
| 156 class PLATFORM_EXPORT {{domain.domain}}{{command.name | to_title_case}}Callback
: public Backend::{{domain.domain}}::{{command.name | to_title_case}}Callback, p
ublic DispatcherCallbackBase { | 156 class PLATFORM_EXPORT {{domain.domain}}{{command.name | to_title_case}}Callback
: public {{domain.domain}}::Backend::{{command.name | to_title_case}}Callback, p
ublic DispatcherCallbackBase { |
| 157 public: | 157 public: |
| 158 {{domain.domain}}{{command.name | to_title_case}}Callback(std::unique_ptr<Di
spatcherImplWeakPtr> backendImpl, int callId) | 158 {{domain.domain}}{{command.name | to_title_case}}Callback(std::unique_ptr<Di
spatcherImplWeakPtr> backendImpl, int callId) |
| 159 : DispatcherCallbackBase(std::move(backendImpl), callId) { } | 159 : DispatcherCallbackBase(std::move(backendImpl), callId) { } |
| 160 | 160 |
| 161 void sendSuccess( | 161 void sendSuccess( |
| 162 {%- for parameter in command.returns -%} | 162 {%- for parameter in command.returns -%} |
| 163 {%- if "optional" in parameter -%} | 163 {%- if "optional" in parameter -%} |
| 164 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} | 164 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} |
| 165 {%- else -%} | 165 {%- else -%} |
| 166 {{resolve_type(parameter).pass_type}} {{parameter.name}} | 166 {{resolve_type(parameter).pass_type}} {{parameter.name}} |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 return false; | 355 return false; |
| 356 | 356 |
| 357 if (!object->getString("method", result)) | 357 if (!object->getString("method", result)) |
| 358 return false; | 358 return false; |
| 359 | 359 |
| 360 return true; | 360 return true; |
| 361 } | 361 } |
| 362 | 362 |
| 363 } // namespace protocol | 363 } // namespace protocol |
| 364 } // namespace blink | 364 } // namespace blink |
| OLD | NEW |