OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/inspector/inspector-impl.h" | 5 #include "test/inspector/inspector-impl.h" |
6 | 6 |
7 #include "include/v8.h" | 7 #include "include/v8.h" |
8 | 8 |
9 #include "src/vector.h" | 9 #include "src/vector.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 const int kInspectorClientIndex = v8::Context::kDebugIdIndex + 1; | 13 const int kInspectorClientIndex = v8::Context::kDebugIdIndex + 1; |
14 | 14 |
15 class ChannelImpl final : public v8_inspector::V8Inspector::Channel { | 15 class ChannelImpl final : public v8_inspector::V8Inspector::Channel { |
16 public: | 16 public: |
17 explicit ChannelImpl(InspectorClientImpl::FrontendChannel* frontend_channel) | 17 explicit ChannelImpl(InspectorClientImpl::FrontendChannel* frontend_channel) |
18 : frontend_channel_(frontend_channel) {} | 18 : frontend_channel_(frontend_channel) {} |
19 virtual ~ChannelImpl() = default; | 19 virtual ~ChannelImpl() = default; |
20 | 20 |
21 private: | 21 private: |
22 void sendProtocolResponse(int callId, | 22 void sendResponse( |
23 const v8_inspector::StringView& message) override { | 23 int callId, |
24 frontend_channel_->SendMessageToFrontend(message); | 24 std::unique_ptr<v8_inspector::StringBuffer> message) override { |
| 25 frontend_channel_->SendMessageToFrontend(message->string()); |
25 } | 26 } |
26 void sendProtocolNotification( | 27 void sendNotification( |
27 const v8_inspector::StringView& message) override { | 28 std::unique_ptr<v8_inspector::StringBuffer> message) override { |
28 frontend_channel_->SendMessageToFrontend(message); | 29 frontend_channel_->SendMessageToFrontend(message->string()); |
29 } | 30 } |
30 void flushProtocolNotifications() override {} | 31 void flushProtocolNotifications() override {} |
31 | 32 |
32 InspectorClientImpl::FrontendChannel* frontend_channel_; | 33 InspectorClientImpl::FrontendChannel* frontend_channel_; |
33 DISALLOW_COPY_AND_ASSIGN(ChannelImpl); | 34 DISALLOW_COPY_AND_ASSIGN(ChannelImpl); |
34 }; | 35 }; |
35 | 36 |
36 InspectorClientImpl* InspectorClientFromContext( | 37 InspectorClientImpl* InspectorClientFromContext( |
37 v8::Local<v8::Context> context) { | 38 v8::Local<v8::Context> context) { |
38 InspectorClientImpl* inspector_client = static_cast<InspectorClientImpl*>( | 39 InspectorClientImpl* inspector_client = static_cast<InspectorClientImpl*>( |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 isolate, SendMessageToBackendExtension::SendMessageToBackend); | 194 isolate, SendMessageToBackendExtension::SendMessageToBackend); |
194 } | 195 } |
195 | 196 |
196 void SendMessageToBackendExtension::SendMessageToBackend( | 197 void SendMessageToBackendExtension::SendMessageToBackend( |
197 const v8::FunctionCallbackInfo<v8::Value>& args) { | 198 const v8::FunctionCallbackInfo<v8::Value>& args) { |
198 CHECK(backend_task_runner_); | 199 CHECK(backend_task_runner_); |
199 CHECK(args.Length() == 1 && args[0]->IsString()); | 200 CHECK(args.Length() == 1 && args[0]->IsString()); |
200 v8::Local<v8::String> message = args[0].As<v8::String>(); | 201 v8::Local<v8::String> message = args[0].As<v8::String>(); |
201 backend_task_runner_->Append(new SendMessageToBackendTask(ToVector(message))); | 202 backend_task_runner_->Append(new SendMessageToBackendTask(ToVector(message))); |
202 } | 203 } |
OLD | NEW |