Commit fdd4d1d1 authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: allow tracing over the remote debugging pipe.

This includes transition from \n to \0 message separation.

Change-Id: I9bcd5690dc848a6d4206d051443be2082d747824
Reviewed-on: https://chromium-review.googlesource.com/1135939Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574785}
parent a16dc5ef
......@@ -71,8 +71,10 @@ bool BrowserDevToolsAgentHost::AttachSession(DevToolsSession* session,
session->AddHandler(std::make_unique<protocol::MemoryHandler>());
session->AddHandler(std::make_unique<protocol::SecurityHandler>());
session->AddHandler(std::make_unique<protocol::SystemInfoHandler>());
session->AddHandler(std::make_unique<protocol::TetheringHandler>(
socket_callback_, tethering_task_runner_));
if (tethering_task_runner_) {
session->AddHandler(std::make_unique<protocol::TetheringHandler>(
socket_callback_, tethering_task_runner_));
}
session->AddHandler(
std::make_unique<protocol::TracingHandler>(nullptr, GetIOContext()));
return true;
......
......@@ -66,9 +66,9 @@ void WriteIntoPipe(int write_fd, const std::string& message) {
}
#if defined(OS_WIN)
DWORD result = 0;
WriteFile(handle, "\n", 1, &result, nullptr);
WriteFile(handle, "\0", 1, &result, nullptr);
#else
int result = write(write_fd, "\n", 1);
int result = write(write_fd, "\0", 1);
#endif
if (!result) {
LOG(ERROR) << "Could not write into pipe";
......@@ -145,11 +145,11 @@ bool PipeReader::HandleReadResult(int result) {
read_buffer_->DidRead(result);
// Go over the last read chunk, look for \n, extract messages.
// Go over the last read chunk, look for \0, extract messages.
int offset = 0;
for (int i = read_buffer_->GetSize() - result; i < read_buffer_->GetSize();
++i) {
if (read_buffer_->StartOfBuffer()[i] == '\n') {
if (read_buffer_->StartOfBuffer()[i] == '\0') {
std::string str(read_buffer_->StartOfBuffer() + offset, i - offset);
BrowserThread::PostTask(
......@@ -190,7 +190,8 @@ DevToolsPipeHandler::DevToolsPipeHandler()
return;
}
browser_target_ = DevToolsAgentHost::CreateForDiscovery();
browser_target_ = DevToolsAgentHost::CreateForBrowser(
nullptr, DevToolsAgentHost::CreateServerSocketCallback());
browser_target_->AttachClient(this);
pipe_reader_.reset(new PipeReader(weak_factory_.GetWeakPtr(), read_fd_));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment