Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Ostroukhov <eostroukhov@google.com>2018-05-22 02:59:04 +0300
committerAnna Henningsen <anna@addaleax.net>2018-07-14 00:42:50 +0300
commit39977db7c015e94d33885249f50e62fa8b1f1bb9 (patch)
treefb330cb04106d7a030b1599549f5503c3ea086ea /src/inspector_socket_server.cc
parent9374a83d6983710844c5436f32c14242ba600a20 (diff)
inspector: split main thread interface from transport
Workers debugging will require interfacing between the "main" inspector and per-worker isolate inspectors. This is consistent with what WS interface does. This change is a refactoring change and does not change the functionality. PR-URL: https://github.com/nodejs/node/pull/21182 Fixes: https://github.com/nodejs/node/issues/21725 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/inspector_socket_server.cc')
-rw-r--r--src/inspector_socket_server.cc31
1 files changed, 6 insertions, 25 deletions
diff --git a/src/inspector_socket_server.cc b/src/inspector_socket_server.cc
index 174dc7c726f..1621b408b43 100644
--- a/src/inspector_socket_server.cc
+++ b/src/inspector_socket_server.cc
@@ -173,11 +173,8 @@ class SocketSession {
InspectorSocket* ws_socket() {
return ws_socket_.get();
}
- void set_ws_key(const std::string& ws_key) {
- ws_key_ = ws_key;
- }
- void Accept() {
- ws_socket_->AcceptUpgrade(ws_key_);
+ void Accept(const std::string& ws_key) {
+ ws_socket_->AcceptUpgrade(ws_key);
}
void Decline() {
ws_socket_->CancelHandshake();
@@ -208,7 +205,6 @@ class SocketSession {
const int id_;
InspectorSocket::Pointer ws_socket_;
const int server_port_;
- std::string ws_key_;
};
class ServerSocket {
@@ -260,11 +256,11 @@ void InspectorSocketServer::SessionStarted(int session_id,
const std::string& ws_key) {
SocketSession* session = Session(session_id);
if (!TargetExists(id)) {
- Session(session_id)->Decline();
+ session->Decline();
return;
}
connected_sessions_[session_id].first = id;
- session->set_ws_key(ws_key);
+ session->Accept(ws_key);
delegate_->StartSession(session_id, id);
}
@@ -404,6 +400,8 @@ bool InspectorSocketServer::Start() {
}
void InspectorSocketServer::Stop() {
+ if (state_ == ServerState::kStopped)
+ return;
CHECK_EQ(state_, ServerState::kRunning);
state_ = ServerState::kStopped;
server_sockets_.clear();
@@ -446,23 +444,6 @@ void InspectorSocketServer::Accept(int server_port,
}
}
-void InspectorSocketServer::AcceptSession(int session_id) {
- SocketSession* session = Session(session_id);
- if (session == nullptr) {
- delegate_->EndSession(session_id);
- } else {
- session->Accept();
- }
-}
-
-void InspectorSocketServer::DeclineSession(int session_id) {
- auto it = connected_sessions_.find(session_id);
- if (it != connected_sessions_.end()) {
- it->second.first.clear();
- it->second.second->Decline();
- }
-}
-
void InspectorSocketServer::Send(int session_id, const std::string& message) {
SocketSession* session = Session(session_id);
if (session != nullptr) {