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

Unified Diff: chrome/test/pyautolib/remote_inspector_client.py

Issue 10795055: Fix 2 threading-related bugs in pyauto's remote inspector module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/remote_inspector_client.py
diff --git a/chrome/test/pyautolib/remote_inspector_client.py b/chrome/test/pyautolib/remote_inspector_client.py
index 37e5884c4936a6b7aaaac1d0808a5cd9d35377dc..2b7ef6ad8006bafbc63a69836e8830f6af435a38 100755
--- a/chrome/test/pyautolib/remote_inspector_client.py
+++ b/chrome/test/pyautolib/remote_inspector_client.py
@@ -361,7 +361,7 @@ class _RemoteInspectorThread(threading.Thread):
self._client.SendMessage(str(request))
request.is_fulfilled_condition.acquire()
- self._condition_to_wait = request.is_fulfilled
+ self._condition_to_wait = request.is_fulfilled_condition
request.is_fulfilled_condition.wait()
request.is_fulfilled_condition.release()
@@ -982,6 +982,7 @@ class RemoteInspectorClient(object):
self._event_callback = event_callback
+ done_condition = threading.Condition()
def HandleReply(reply_dict):
"""Processes a reply message received from the remote Chrome instance.
@@ -989,14 +990,22 @@ class RemoteInspectorClient(object):
reply_dict: A dictionary object representing the reply message received
from the remote Chrome instance.
"""
+ if 'result' in reply_dict:
+ done_condition.acquire()
+ done_condition.notify()
+ done_condition.release()
if reply_dict.get('method') == 'Timeline.eventRecorded':
self._event_callback(reply_dict['params']['record'])
- # Tell the remote inspector to start the timeline. We can return
- # immediately, since there is no result for which to wait.
+ # Tell the remote inspector to start the timeline.
self._timeline_callback = HandleReply
self._remote_inspector_thread.AddMessageCallback(self._timeline_callback)
self._remote_inspector_thread.PerformAction(TIMELINE_MESSAGES, None)
+
+ done_condition.acquire()
+ done_condition.wait()
+ done_condition.release()
+
self._timeline_started = True
def StopTimelineEventMonitoring(self):
@@ -1008,10 +1017,27 @@ class RemoteInspectorClient(object):
('Timeline.stop', {})
]
- # Tell the remote inspector to stop the timeline. We can return
- # immediately, since there is no result for which to wait.
+ done_condition = threading.Condition()
+ def HandleReply(reply_dict):
+ """Processes a reply message received from the remote Chrome instance.
+
+ Args:
+ reply_dict: A dictionary object representing the reply message received
+ from the remote Chrome instance.
+ """
+ if 'result' in reply_dict:
+ done_condition.acquire()
+ done_condition.notify()
+ done_condition.release()
+
+ # Tell the remote inspector to stop the timeline.
self._remote_inspector_thread.RemoveMessageCallback(self._timeline_callback)
- self._remote_inspector_thread.PerformAction(TIMELINE_MESSAGES, None)
+ self._remote_inspector_thread.PerformAction(TIMELINE_MESSAGES, HandleReply)
+
+ done_condition.acquire()
+ done_condition.wait()
+ done_condition.release()
+
self._timeline_started = False
def _ConvertByteCountToHumanReadableString(self, num_bytes):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698