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

Unified Diff: chrome/test/chromedriver/devtools_client_impl.cc

Issue 12230021: [chromedriver] Send all OnConnected before any OnEvent when connected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« no previous file with comments | « chrome/test/chromedriver/devtools_client_impl.h ('k') | chrome/test/chromedriver/dom_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « chrome/test/chromedriver/devtools_client_impl.h ('k') | chrome/test/chromedriver/dom_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698