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

Unified Diff: third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/interface.tmpl

Issue 1019173002: Update mojo sdk to rev 7214b7ec7d27563b2666afad86cf1c5895c56c18 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep permission service alive if embedder drops requests Created 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
diff --git a/third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/interface.tmpl b/third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
index 32ba383839d33b2e04724db70654b5ccd3283c05..c96441eaa105cf7c3b819df84d640659c06c59e7 100644
--- a/third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
+++ b/third_party/mojo/src/mojo/public/tools/bindings/generators/go_templates/interface.tmpl
@@ -23,13 +23,13 @@
-{%- macro flags(response_parameters, is_renponse) -%}
+{%- macro flags(response_parameters, is_response) -%}
{%- if not response_parameters -%}
bindings.MessageNoFlag
-{%- elif is_parameter: -%}
- bindings.MessageExpectsResponseFlag
-{%- else -%}
+{%- elif is_response: -%}
bindings.MessageIsResponseFlag
+{%- else -%}
+ bindings.MessageExpectsResponseFlag
{%- endif -%}
{%- endmacro -%}
@@ -45,19 +45,26 @@ type {{interface|name}} interface {
type {{interface|name}}Request bindings.InterfaceRequest
type {{interface|name}}Pointer bindings.InterfacePointer
+// CreateMessagePipeFor{{interface|name}} creates a message pipe for use with the
+// {{interface|name}} interface with a {{interface|name}}Request on one end and a {{interface|name}}Pointer on the other.
+func CreateMessagePipeFor{{interface|name}}() ({{interface|name}}Request, {{interface|name}}Pointer) {
+ r, p := bindings.CreateMessagePipeForMojoInterface()
+ return {{interface|name}}Request(r), {{interface|name}}Pointer(p)
+}
+
{% for method in interface.methods %}
const {{interface|name(False)}}_{{method|name}}_Name = {{method.ordinal}}
{% endfor %}
type {{interface|name}}Proxy struct {
router *bindings.Router
- ids *bindings.Counter
+ ids bindings.Counter
}
func New{{interface|name}}Proxy(p {{interface|name}}Pointer, waiter bindings.AsyncWaiter) *{{interface|name}}Proxy {
return &{{interface|name}}Proxy{
bindings.NewRouter(p.PassMessagePipe(), waiter),
- &bindings.Counter{},
+ bindings.NewCounter(),
}
}
@@ -80,29 +87,35 @@ func (p *{{interface|name}}Proxy) {{method|name}}{{declare_request_params(method
Type: {{interface|name(False)}}_{{method|name}}_Name,
Flags: {{flags(method.response_parameters, False)}},
{% if method.response_parameters %}
- RequestId: p.ids.Next(),
+ RequestId: p.ids.Count(),
{% endif %}
}
var message *bindings.Message
if message, err = bindings.EncodeMessage(header, payload); err != nil {
err = fmt.Errorf("can't encode request: %v", err.Error())
+ p.Close_proxy()
return
}
{% if method.response_parameters %}
readResult := <-p.router.AcceptWithResponse(message)
if err = readResult.Error; err != nil {
+ p.Close_proxy()
return
}
var response {{method|response_struct_from_method|name(False)}}
if err = readResult.Message.DecodePayload(&response); err != nil {
err = fmt.Errorf("can't decode response: %v", err.Error())
+ p.Close_proxy()
return
}
{% for field in (method|response_struct_from_method).fields %}
{{field|name(False)}} = response.{{field|name(False)}}
{% endfor %}
{% else %}
- err = p.router.Accept(message)
+ if err = p.router.Accept(message); err != nil {
+ p.Close_proxy()
+ return
+ }
{% endif %}
return
}

Powered by Google App Engine
This is Rietveld 408576698