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

Side by Side Diff: test/inspector-protocol/inspector-impl.cc

Issue 2372793002: [inspector] added inspector test runner [part 3] (Closed)
Patch Set: rebased Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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-protocol/inspector-impl.h" 5 #include "test/inspector-protocol/inspector-impl.h"
6 6
7 #include "include/v8.h" 7 #include "include/v8.h"
8 #include "src/inspector/string-16.h" 8 #include "src/inspector/string-16.h"
9 9
10 namespace { 10 namespace {
(...skipping 23 matching lines...) Expand all
34 34
35 v8_inspector::String16 ToString16(const v8_inspector::StringView& string) { 35 v8_inspector::String16 ToString16(const v8_inspector::StringView& string) {
36 if (string.is8Bit()) 36 if (string.is8Bit())
37 return v8_inspector::String16( 37 return v8_inspector::String16(
38 reinterpret_cast<const char*>(string.characters8()), string.length()); 38 reinterpret_cast<const char*>(string.characters8()), string.length());
39 return v8_inspector::String16( 39 return v8_inspector::String16(
40 reinterpret_cast<const uint16_t*>(string.characters16()), 40 reinterpret_cast<const uint16_t*>(string.characters16()),
41 string.length()); 41 string.length());
42 } 42 }
43 43
44 InspectorClientImpl* InspectorClientFromContext(
45 v8::Local<v8::Context> context) {
46 InspectorClientImpl* inspector_client = static_cast<InspectorClientImpl*>(
47 context->GetAlignedPointerFromEmbedderData(kInspectorClientIndex));
48 CHECK(inspector_client);
49 return inspector_client;
50 }
51
44 } // namespace 52 } // namespace
45 53
46 class ConnectTask : public TaskRunner::Task { 54 class ConnectTask : public TaskRunner::Task {
47 public: 55 public:
48 ConnectTask(InspectorClientImpl* client, v8::base::Semaphore* ready_semaphore) 56 ConnectTask(InspectorClientImpl* client, v8::base::Semaphore* ready_semaphore)
49 : client_(client), ready_semaphore_(ready_semaphore) {} 57 : client_(client), ready_semaphore_(ready_semaphore) {}
50 virtual ~ConnectTask() {} 58 virtual ~ConnectTask() {}
51 59
52 bool is_inspector_task() final { return true; } 60 bool is_inspector_task() final { return true; }
53 61
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 106 }
99 107
100 void InspectorClientImpl::runMessageLoopOnPause(int) { 108 void InspectorClientImpl::runMessageLoopOnPause(int) {
101 task_runner_->RunMessageLoop(true); 109 task_runner_->RunMessageLoop(true);
102 } 110 }
103 111
104 void InspectorClientImpl::quitMessageLoopOnPause() { 112 void InspectorClientImpl::quitMessageLoopOnPause() {
105 task_runner_->QuitMessageLoop(); 113 task_runner_->QuitMessageLoop();
106 } 114 }
107 115
116 v8_inspector::V8Inspector* InspectorClientImpl::InspectorFromContext(
117 v8::Local<v8::Context> context) {
118 return InspectorClientFromContext(context)->inspector_.get();
119 }
120
108 v8_inspector::V8InspectorSession* InspectorClientImpl::SessionFromContext( 121 v8_inspector::V8InspectorSession* InspectorClientImpl::SessionFromContext(
109 v8::Local<v8::Context> context) { 122 v8::Local<v8::Context> context) {
110 InspectorClientImpl* inspector_client = static_cast<InspectorClientImpl*>( 123 return InspectorClientFromContext(context)->session_.get();
111 context->GetAlignedPointerFromEmbedderData(kInspectorClientIndex));
112 CHECK(inspector_client);
113 return inspector_client->session_.get();
114 } 124 }
115 125
116 class SendMessageToBackendTask : public TaskRunner::Task { 126 class SendMessageToBackendTask : public TaskRunner::Task {
117 public: 127 public:
118 SendMessageToBackendTask(const v8_inspector::StringView& message) 128 SendMessageToBackendTask(const v8_inspector::StringView& message)
119 : message_(ToString16(message)) {} 129 : message_(ToString16(message)) {}
120 130
121 bool is_inspector_task() final { return true; } 131 bool is_inspector_task() final { return true; }
122 132
123 void Run(v8::Isolate* isolate, 133 void Run(v8::Isolate* isolate,
(...skipping 28 matching lines...) Expand all
152 const v8::FunctionCallbackInfo<v8::Value>& args) { 162 const v8::FunctionCallbackInfo<v8::Value>& args) {
153 CHECK(backend_task_runner_); 163 CHECK(backend_task_runner_);
154 CHECK(args.Length() == 1 && args[0]->IsString()); 164 CHECK(args.Length() == 1 && args[0]->IsString());
155 v8::Local<v8::String> message = args[0].As<v8::String>(); 165 v8::Local<v8::String> message = args[0].As<v8::String>();
156 std::unique_ptr<uint16_t[]> buffer(new uint16_t[message->Length()]); 166 std::unique_ptr<uint16_t[]> buffer(new uint16_t[message->Length()]);
157 message.As<v8::String>()->Write(reinterpret_cast<uint16_t*>(buffer.get()), 0, 167 message.As<v8::String>()->Write(reinterpret_cast<uint16_t*>(buffer.get()), 0,
158 message->Length()); 168 message->Length());
159 backend_task_runner_->Append(new SendMessageToBackendTask( 169 backend_task_runner_->Append(new SendMessageToBackendTask(
160 v8_inspector::StringView(buffer.get(), message->Length()))); 170 v8_inspector::StringView(buffer.get(), message->Length())));
161 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698