| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * |
| 3 * Copyright 2015-2016, Google Inc. |
| 4 * All rights reserved. |
| 3 * | 5 * |
| 4 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 6 * met: | 8 * met: |
| 7 * | 9 * |
| 8 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 11 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 12 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer | 13 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 14 * in the documentation and/or other materials provided with the |
| 13 * distribution. | 15 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its | 16 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from | 17 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. | 18 * this software without specific prior written permission. |
| 17 * | 19 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 * |
| 29 */ | 32 */ |
| 30 | 33 |
| 31 #ifndef InspectorFrontendClient_h | 34 #include "src/core/surface/channel.h" |
| 32 #define InspectorFrontendClient_h | |
| 33 | 35 |
| 34 #include "platform/heap/Handle.h" | 36 #include <string.h> |
| 35 #include "wtf/Forward.h" | |
| 36 | 37 |
| 37 namespace blink { | 38 #include <grpc/support/alloc.h> |
| 39 #include <grpc/support/log.h> |
| 38 | 40 |
| 39 class ContextMenuProvider; | 41 #include "src/core/surface/api_trace.h" |
| 40 class LocalFrame; | 42 #include "src/core/surface/completion_queue.h" |
| 41 | 43 |
| 42 class InspectorFrontendClient { | 44 typedef struct { |
| 43 public: | 45 grpc_closure closure; |
| 44 virtual ~InspectorFrontendClient() { } | 46 void *tag; |
| 47 grpc_completion_queue *cq; |
| 48 grpc_cq_completion completion_storage; |
| 49 } ping_result; |
| 45 | 50 |
| 46 virtual void sendMessageToEmbedder(const String&) = 0; | 51 static void ping_destroy(grpc_exec_ctx *exec_ctx, void *arg, |
| 52 grpc_cq_completion *storage) { |
| 53 gpr_free(arg); |
| 54 } |
| 47 | 55 |
| 48 virtual bool isUnderTest() = 0; | 56 static void ping_done(grpc_exec_ctx *exec_ctx, void *arg, bool success) { |
| 57 ping_result *pr = arg; |
| 58 grpc_cq_end_op(exec_ctx, pr->cq, pr->tag, success, ping_destroy, pr, |
| 59 &pr->completion_storage); |
| 60 } |
| 49 | 61 |
| 50 virtual void showContextMenu(LocalFrame* targetFrame, float x, float y, Cont
extMenuProvider*) = 0; | 62 void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq, |
| 51 | 63 void *tag, void *reserved) { |
| 52 virtual void setInjectedScriptForOrigin(const String& origin, const String&
source) = 0; | 64 grpc_transport_op op; |
| 53 }; | 65 ping_result *pr = gpr_malloc(sizeof(*pr)); |
| 54 | 66 grpc_channel_element *top_elem = |
| 55 } // namespace blink | 67 grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0); |
| 56 | 68 grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
| 57 #endif | 69 GPR_ASSERT(reserved == NULL); |
| 70 memset(&op, 0, sizeof(op)); |
| 71 pr->tag = tag; |
| 72 pr->cq = cq; |
| 73 grpc_closure_init(&pr->closure, ping_done, pr); |
| 74 op.send_ping = &pr->closure; |
| 75 op.bind_pollset = grpc_cq_pollset(cq); |
| 76 grpc_cq_begin_op(cq, tag); |
| 77 top_elem->filter->start_transport_op(&exec_ctx, top_elem, &op); |
| 78 grpc_exec_ctx_finish(&exec_ctx); |
| 79 } |
| OLD | NEW |