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

Unified Diff: content/browser/devtools/devtools_session.cc

Issue 2933243002: [DevTools] Make DevToolsSession own it's DevToolsMessageChunkProcessor (Closed)
Patch Set: addressed comments Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/devtools/devtools_session.cc
diff --git a/content/browser/devtools/devtools_session.cc b/content/browser/devtools/devtools_session.cc
index f9dcb58e6b090f99032a52d319f33350e2c4ff6f..528fa56d79063308e685ff0947a7499d55e45941 100644
--- a/content/browser/devtools/devtools_session.cc
+++ b/content/browser/devtools/devtools_session.cc
@@ -20,6 +20,8 @@ DevToolsSession::DevToolsSession(DevToolsAgentHostImpl* agent_host,
session_id_(session_id),
host_(nullptr),
dispatcher_(new protocol::UberDispatcher(this)),
+ chunk_processor_(base::Bind(&DevToolsSession::SendMessageToClient,
+ base::Unretained(this))),
weak_factory_(this) {}
DevToolsSession::~DevToolsSession() {
@@ -46,11 +48,21 @@ void DevToolsSession::SetFallThroughForNotFound(bool value) {
dispatcher_->setFallThroughForNotFound(value);
}
-void DevToolsSession::sendResponse(
+void DevToolsSession::SendMessageToClient(int session_id,
+ const std::string& message) {
+ if (session_id != session_id_)
+ return;
+ int id = chunk_processor_.last_call_id();
+ waiting_for_response_messages_.erase(id);
+ client_->DispatchProtocolMessage(agent_host_, message);
+ // |this| may be deleted at this point.
+}
+
+void DevToolsSession::SendResponse(
std::unique_ptr<base::DictionaryValue> response) {
std::string json;
base::JSONWriter::Write(*response.get(), &json);
- agent_host_->SendMessageToClient(session_id_, json);
+ client_->DispatchProtocolMessage(agent_host_, json);
}
protocol::Response::Status DevToolsSession::Dispatch(
@@ -67,11 +79,11 @@ protocol::Response::Status DevToolsSession::Dispatch(
std::unique_ptr<base::DictionaryValue> response(
delegate->HandleCommand(agent_host_, dict_value));
if (response) {
- sendResponse(std::move(response));
+ SendResponse(std::move(response));
return protocol::Response::kSuccess;
}
if (delegate->HandleAsyncCommand(agent_host_, dict_value,
- base::Bind(&DevToolsSession::sendResponse,
+ base::Bind(&DevToolsSession::SendResponse,
weak_factory_.GetWeakPtr()))) {
return protocol::Response::kAsync;
}
@@ -81,15 +93,19 @@ protocol::Response::Status DevToolsSession::Dispatch(
call_id, method);
}
+bool DevToolsSession::ReceiveMessageChunk(const DevToolsMessageChunk& chunk) {
+ return chunk_processor_.ProcessChunkedMessageFromAgent(chunk);
+}
+
void DevToolsSession::sendProtocolResponse(
int call_id,
std::unique_ptr<protocol::Serializable> message) {
- agent_host_->SendMessageToClient(session_id_, message->serialize());
+ client_->DispatchProtocolMessage(agent_host_, message->serialize());
}
void DevToolsSession::sendProtocolNotification(
std::unique_ptr<protocol::Serializable> message) {
- agent_host_->SendMessageToClient(session_id_, message->serialize());
+ client_->DispatchProtocolMessage(agent_host_, message->serialize());
}
void DevToolsSession::flushProtocolNotifications() {
« no previous file with comments | « content/browser/devtools/devtools_session.h ('k') | content/browser/devtools/render_frame_devtools_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698