Index: chrome/test/chromedriver/devtools_client_impl.cc |
diff --git a/chrome/test/chromedriver/devtools_client_impl.cc b/chrome/test/chromedriver/devtools_client_impl.cc |
index 25415a9636c74e78f46d01cc58bc7c4708d026f2..1eb0cb8475d3806ff7db31922debe27b3abea4d7 100644 |
--- a/chrome/test/chromedriver/devtools_client_impl.cc |
+++ b/chrome/test/chromedriver/devtools_client_impl.cc |
@@ -126,12 +126,9 @@ Status DevToolsClientImpl::SendCommandInternal( |
if (!socket_->Connect(url_)) |
return Status(kDisconnected, "unable to connect to renderer"); |
connected_ = true; |
- for (std::list<DevToolsEventListener*>::iterator iter = listeners_.begin(); |
- iter != listeners_.end(); ++iter) { |
- Status status = (*iter)->OnConnected(); |
- if (status.IsError()) |
- return status; |
- } |
+ |
+ // OnConnected notification will be sent out in method ReceiveNextMessage. |
+ listeners_for_on_connected_ = listeners_; |
craigdh
2013/02/13 19:19:39
Instead of copying the list, why not just have a b
kkania
2013/02/13 20:57:34
then you'd also have to keep track of what listene
craigdh
2013/02/13 21:45:45
Ah, I see the issue. Agreed.
chrisgao (Use stgao instead)
2013/02/14 03:49:45
I also think list copy is easier and simpler.
|
} |
int command_id = next_id_++; |
@@ -170,6 +167,19 @@ Status DevToolsClientImpl::ReceiveNextMessage( |
internal::InspectorMessageType* type, |
internal::InspectorEvent* event, |
internal::InspectorCommandResponse* response) { |
+ while (!listeners_for_on_connected_.empty()) { |
+ DevToolsEventListener* listener = listeners_for_on_connected_.front(); |
+ listeners_for_on_connected_.pop_front(); |
+ Status status = listener->OnConnected(); |
+ if (status.IsError()) |
+ return status; |
+ } |
+ // The message might be received already when processing other commands sent |
+ // from DevToolsEventListener::OnConnected. |
+ if (cmd_response_map_.find(expected_id) != cmd_response_map_.end() |
craigdh
2013/02/13 19:19:39
Consider making this a private function, something
chrisgao (Use stgao instead)
2013/02/14 03:49:45
Good idea.
|
+ && cmd_response_map_[expected_id]) |
+ return Status(kOk); |
+ |
std::string message; |
if (!socket_->ReceiveNextMessage(&message)) { |
connected_ = false; |