Index: chrome/test/chromedriver/chrome/devtools_client_impl.cc |
diff --git a/chrome/test/chromedriver/chrome/devtools_client_impl.cc b/chrome/test/chromedriver/chrome/devtools_client_impl.cc |
index c9191916bd082afc6b5f3b189f905ff8a1bcab60..2148a0eb648cc16079ad0f5f766215e0ebdb525c 100644 |
--- a/chrome/test/chromedriver/chrome/devtools_client_impl.cc |
+++ b/chrome/test/chromedriver/chrome/devtools_client_impl.cc |
@@ -70,13 +70,11 @@ DevToolsClientImpl::DevToolsClientImpl( |
const SyncWebSocketFactory& factory, |
const std::string& url, |
const std::string& id, |
- const FrontendCloserFunc& frontend_closer_func, |
- Log* log) |
+ const FrontendCloserFunc& frontend_closer_func) |
: socket_(factory.Run().Pass()), |
url_(url), |
id_(id), |
frontend_closer_func_(frontend_closer_func), |
- log_(log), |
parser_func_(base::Bind(&internal::ParseInspectorMessage)), |
unnotified_event_(NULL), |
next_id_(1), |
@@ -87,13 +85,11 @@ DevToolsClientImpl::DevToolsClientImpl( |
const std::string& url, |
const std::string& id, |
const FrontendCloserFunc& frontend_closer_func, |
- Log* log, |
const ParserFunc& parser_func) |
: socket_(factory.Run().Pass()), |
url_(url), |
id_(id), |
frontend_closer_func_(frontend_closer_func), |
- log_(log), |
parser_func_(parser_func), |
unnotified_event_(NULL), |
next_id_(1), |
@@ -207,9 +203,11 @@ Status DevToolsClientImpl::SendCommandInternal( |
command.SetInteger("id", command_id); |
command.SetString("method", method); |
command.Set("params", params.DeepCopy()); |
- std::string message; |
- base::JSONWriter::Write(&command, &message); |
- log_->AddEntry(Log::kDebug, "sending Inspector command " + message); |
+ std::string message = SerializeValue(&command); |
chrisgao (Use stgao instead)
2013/09/05 01:20:46
I'm not sure whether we should put SerializeValue
kkania
2013/09/05 15:15:11
Done.
|
+ if (IsVLogOn(1)) { |
+ VLOG(1) << "Sending " << method << " (id=" << command_id << ") " |
+ << SerializeValue(¶ms); |
chrisgao (Use stgao instead)
2013/09/05 01:20:46
For javascript, this could print a bunch of log.
kkania
2013/09/05 15:15:11
Done.
|
+ } |
if (!socket_->Send(message)) |
return Status(kDisconnected, "unable to send message to renderer"); |
@@ -260,15 +258,12 @@ Status DevToolsClientImpl::ProcessNextMessage( |
std::string message; |
switch (socket_->ReceiveNextMessage(&message, timeout)) { |
case SyncWebSocket::kOk: |
- log_->AddEntry(Log::kDebug, "received Inspector response " + message); |
break; |
case SyncWebSocket::kDisconnected: |
- message = "unable to receive message from renderer"; |
- log_->AddEntry(Log::kDebug, message); |
+ LOG(ERROR) << "Unable to receive message from renderer"; |
return Status(kDisconnected, message); |
case SyncWebSocket::kTimeout: |
- message = "timed out receiving message from renderer"; |
- log_->AddEntry(Log::kDebug, message); |
+ LOG(ERROR) << "timed out receiving message from renderer"; |
return Status(kTimeout, message); |
default: |
NOTREACHED(); |
@@ -278,8 +273,10 @@ Status DevToolsClientImpl::ProcessNextMessage( |
internal::InspectorMessageType type; |
internal::InspectorEvent event; |
internal::InspectorCommandResponse response; |
- if (!parser_func_.Run(message, expected_id, &type, &event, &response)) |
+ if (!parser_func_.Run(message, expected_id, &type, &event, &response)) { |
+ LOG(ERROR) << "Bad inspector message: " << message; |
return Status(kUnknownError, "bad inspector message: " + message); |
+ } |
if (type == internal::kEventMessageType) |
return ProcessEvent(event); |
@@ -288,6 +285,10 @@ Status DevToolsClientImpl::ProcessNextMessage( |
} |
Status DevToolsClientImpl::ProcessEvent(const internal::InspectorEvent& event) { |
+ if (IsVLogOn(1)) { |
+ VLOG(1) << "Received " << event.method << " " |
chrisgao (Use stgao instead)
2013/09/05 01:20:46
"Received " -> "Received event "?
kkania
2013/09/05 15:15:11
changed to EVENT
|
+ << SerializeValue(event.params.get()); |
+ } |
unnotified_event_listeners_ = listeners_; |
unnotified_event_ = &event; |
Status status = EnsureListenersNotifiedOfEvent(); |
@@ -327,7 +328,20 @@ Status DevToolsClientImpl::ProcessEvent(const internal::InspectorEvent& event) { |
Status DevToolsClientImpl::ProcessCommandResponse( |
const internal::InspectorCommandResponse& response) { |
- if (response_info_map_.count(response.id) == 0) |
+ ResponseInfoMap::iterator iter = response_info_map_.find(response.id); |
+ if (IsVLogOn(1)) { |
+ std::string method, result; |
+ if (iter != response_info_map_.end()) |
+ method = iter->second->method; |
+ if (response.result) |
+ result = SerializeValue(response.result.get()); |
+ else |
+ result = response.error; |
+ VLOG(1) << "Received response for " << method << " (id=" << response.id |
+ << ") " << result; |
+ } |
+ |
+ if (iter == response_info_map_.end()) |
return Status(kUnknownError, "unexpected command response"); |
linked_ptr<ResponseInfo> response_info = response_info_map_[response.id]; |