Revert 145455 - Revert 145403 - Fix a couple threading bugs in pyauto's remote inspector client module.
Revert 145455 - Revert 145403 - Fix a couple threading bugs in pyauto's remote inspector client module.

Specific changes made in this CL:

(1) Add locks around two variables that can be accessed by multiple threads
simultaneously.  This should fix a bug where 2 statements of the form:

if x is not None:
  x()

Would sometimes throw an error because x might have changed to None in-between
the two statements above.

(2) Fixed a bug where a request was considered "done" before any callbacks
associated with it were notified.  This led to flakiness where the callbacks
were not always being executed when they needed to be.  The fix is to wait until
after the callbacks are notified, before considering the request to be "done".

This CL should fix all of the Chrome Endure bots that started failing recently
with hangs in the remote inspector client module.

BUG=None
TEST=Invoked the remote inspector client a couple thousand times without seeing
any hangs, whereas before this change, we'd often see a hang within the first
500 invocations.
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/10703086

TBR=dennisjeffrey@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10704098

TBR=stevet@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10704236

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@146892 0039d316-1c4b-4281-b951-d872f2087c98

Fireblend/chromium-crosswalk,jaruba/chromium.src,hgl888/chromium-crosswalk-efl,mogoweb/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,ChromiumWebApps/chromium,ltilve/chromium,Jonekee/chromium.src,ondra-novak/chromium.src,mohamed--abdel-maksoud/chromium.src,mohamed--abdel-maksoud/chromium.src,hujiajie/pa-chromium,ChromiumWebApps/chromium,axinging/chromium-crosswalk,junmin-zhu/chromium-rivertrail,chuan9/chromium-crosswalk,hgl888/chromium-crosswalk,ondra-novak/chromium.src,Fireblend/chromium-crosswalk,keishi/chromium,pozdnyakov/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,mogoweb/chromium-crosswalk,Pluto-tv/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,timopulkkinen/BubbleFish,Just-D/chromium-1,zcbenz/cefode-chromium,littlstar/chromium.src,krieger-od/nwjs_chromium.src,nacl-webkit/chrome_deps,Just-D/chromium-1,anirudhSK/chromium,Chilledheart/chromium,chuan9/chromium-crosswalk,krieger-od/nwjs_chromium.src,anirudhSK/chromium,axinging/chromium-crosswalk,timopulkkinen/BubbleFish,keishi/chromium,nacl-webkit/chrome_deps,hgl888/chromium-crosswalk,anirudhSK/chromium,keishi/chromium,dednal/chromium.src,dushu1203/chromium.src,hgl888/chromium-crosswalk,dushu1203/chromium.src,mogoweb/chromium-crosswalk,hgl888/chromium-crosswalk,ChromiumWebApps/chromium,crosswalk-project/chromium-crosswalk-efl,ChromiumWebApps/chromium,fujunwei/chromium-crosswalk,jaruba/chromium.src,nacl-webkit/chrome_deps,jaruba/chromium.src,ChromiumWebApps/chromium,keishi/chromium,hgl888/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,Fireblend/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,Just-D/chromium-1,hujiajie/pa-chromium,dednal/chromium.src,fujunwei/chromium-crosswalk,M4sse/chromium.src,dushu1203/chromium.src,Jonekee/chromium.src,mohamed--abdel-maksoud/chromium.src,dednal/chromium.src,Jonekee/chromium.src,chuan9/chromium-crosswalk,Just-D/chromium-1,anirudhSK/chromium,anirudhSK/chromium,junmin-zhu/chromium-rivertrail,crosswalk-project/chromium-crosswalk-efl,bright-sparks/chromium-spacewalk,pozdnyakov/chromium-crosswalk,mogoweb/chromium-crosswalk,zcbenz/cefode-chromium,junmin-zhu/chromium-rivertrail,Pluto-tv/chromium-crosswalk,hgl888/chromium-crosswalk-efl,bright-sparks/chromium-spacewalk,hgl888/chromium-crosswalk-efl,mogoweb/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,dushu1203/chromium.src,bright-sparks/chromium-spacewalk,littlstar/chromium.src,mogoweb/chromium-crosswalk,hujiajie/pa-chromium,Chilledheart/chromium,hujiajie/pa-chromium,dednal/chromium.src,timopulkkinen/BubbleFish,bright-sparks/chromium-spacewalk,ondra-novak/chromium.src,nacl-webkit/chrome_deps,Jonekee/chromium.src,chuan9/chromium-crosswalk,bright-sparks/chromium-spacewalk,dushu1203/chromium.src,anirudhSK/chromium,PeterWangIntel/chromium-crosswalk,bright-sparks/chromium-spacewalk,littlstar/chromium.src,hgl888/chromium-crosswalk-efl,Pluto-tv/chromium-crosswalk,markYoungH/chromium.src,crosswalk-project/chromium-crosswalk-efl,nacl-webkit/chrome_deps,dednal/chromium.src,hgl888/chromium-crosswalk,axinging/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,zcbenz/cefode-chromium,jaruba/chromium.src,axinging/chromium-crosswalk,Fireblend/chromium-crosswalk,timopulkkinen/BubbleFish,axinging/chromium-crosswalk,junmin-zhu/chromium-rivertrail,ChromiumWebApps/chromium,nacl-webkit/chrome_deps,Chilledheart/chromium,hgl888/chromium-crosswalk,krieger-od/nwjs_chromium.src,chuan9/chromium-crosswalk,Chilledheart/chromium,zcbenz/cefode-chromium,dednal/chromium.src,Pluto-tv/chromium-crosswalk,junmin-zhu/chromium-rivertrail,M4sse/chromium.src,zcbenz/cefode-chromium,bright-sparks/chromium-spacewalk,TheTypoMaster/chromium-crosswalk,patrickm/chromium.src,mohamed--abdel-maksoud/chromium.src,nacl-webkit/chrome_deps,mogoweb/chromium-crosswalk,ChromiumWebApps/chromium,patrickm/chromium.src,anirudhSK/chromium,keishi/chromium,markYoungH/chromium.src,fujunwei/chromium-crosswalk,patrickm/chromium.src,axinging/chromium-crosswalk,zcbenz/cefode-chromium,fujunwei/chromium-crosswalk,ltilve/chromium,ChromiumWebApps/chromium,krieger-od/nwjs_chromium.src,TheTypoMaster/chromium-crosswalk,Chilledheart/chromium,ltilve/chromium,TheTypoMaster/chromium-crosswalk,nacl-webkit/chrome_deps,Jonekee/chromium.src,fujunwei/chromium-crosswalk,Pluto-tv/chromium-crosswalk,hgl888/chromium-crosswalk-efl,Pluto-tv/chromium-crosswalk,anirudhSK/chromium,timopulkkinen/BubbleFish,dushu1203/chromium.src,Just-D/chromium-1,mohamed--abdel-maksoud/chromium.src,PeterWangIntel/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,bright-sparks/chromium-spacewalk,patrickm/chromium.src,mohamed--abdel-maksoud/chromium.src,keishi/chromium,patrickm/chromium.src,crosswalk-project/chromium-crosswalk-efl,markYoungH/chromium.src,mogoweb/chromium-crosswalk,M4sse/chromium.src,TheTypoMaster/chromium-crosswalk,anirudhSK/chromium,hgl888/chromium-crosswalk,nacl-webkit/chrome_deps,krieger-od/nwjs_chromium.src,zcbenz/cefode-chromium,ChromiumWebApps/chromium,axinging/chromium-crosswalk,dednal/chromium.src,keishi/chromium,M4sse/chromium.src,mohamed--abdel-maksoud/chromium.src,dushu1203/chromium.src,markYoungH/chromium.src,Chilledheart/chromium,pozdnyakov/chromium-crosswalk,ltilve/chromium,M4sse/chromium.src,axinging/chromium-crosswalk,anirudhSK/chromium,ltilve/chromium,zcbenz/cefode-chromium,Fireblend/chromium-crosswalk,anirudhSK/chromium,crosswalk-project/chromium-crosswalk-efl,timopulkkinen/BubbleFish,patrickm/chromium.src,Jonekee/chromium.src,Jonekee/chromium.src,keishi/chromium,axinging/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,pozdnyakov/chromium-crosswalk,markYoungH/chromium.src,nacl-webkit/chrome_deps,junmin-zhu/chromium-rivertrail,markYoungH/chromium.src,littlstar/chromium.src,jaruba/chromium.src,ChromiumWebApps/chromium,bright-sparks/chromium-spacewalk,PeterWangIntel/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,Jonekee/chromium.src,pozdnyakov/chromium-crosswalk,keishi/chromium,dushu1203/chromium.src,Jonekee/chromium.src,patrickm/chromium.src,ondra-novak/chromium.src,chuan9/chromium-crosswalk,markYoungH/chromium.src,hgl888/chromium-crosswalk-efl,jaruba/chromium.src,hujiajie/pa-chromium,anirudhSK/chromium,hgl888/chromium-crosswalk,ondra-novak/chromium.src,pozdnyakov/chromium-crosswalk,M4sse/chromium.src,Jonekee/chromium.src,Just-D/chromium-1,littlstar/chromium.src,mogoweb/chromium-crosswalk,nacl-webkit/chrome_deps,axinging/chromium-crosswalk,axinging/chromium-crosswalk,ChromiumWebApps/chromium,ltilve/chromium,krieger-od/nwjs_chromium.src,keishi/chromium,ondra-novak/chromium.src,pozdnyakov/chromium-crosswalk,hujiajie/pa-chromium,markYoungH/chromium.src,krieger-od/nwjs_chromium.src,crosswalk-project/chromium-crosswalk-efl,M4sse/chromium.src,M4sse/chromium.src,jaruba/chromium.src,keishi/chromium,Pluto-tv/chromium-crosswalk,Just-D/chromium-1,ondra-novak/chromium.src,pozdnyakov/chromium-crosswalk,krieger-od/nwjs_chromium.src,ondra-novak/chromium.src,timopulkkinen/BubbleFish,krieger-od/nwjs_chromium.src,Fireblend/chromium-crosswalk,Jonekee/chromium.src,M4sse/chromium.src,fujunwei/chromium-crosswalk,jaruba/chromium.src,dushu1203/chromium.src,fujunwei/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,ondra-novak/chromium.src,ChromiumWebApps/chromium,markYoungH/chromium.src,dednal/chromium.src,Chilledheart/chromium,timopulkkinen/BubbleFish,hujiajie/pa-chromium,mogoweb/chromium-crosswalk,patrickm/chromium.src,hgl888/chromium-crosswalk-efl,chuan9/chromium-crosswalk,pozdnyakov/chromium-crosswalk,zcbenz/cefode-chromium,hujiajie/pa-chromium,M4sse/chromium.src,littlstar/chromium.src,jaruba/chromium.src,markYoungH/chromium.src,Pluto-tv/chromium-crosswalk,chuan9/chromium-crosswalk,dushu1203/chromium.src,junmin-zhu/chromium-rivertrail,timopulkkinen/BubbleFish,Just-D/chromium-1,junmin-zhu/chromium-rivertrail,timopulkkinen/BubbleFish,dednal/chromium.src,hgl888/chromium-crosswalk-efl,pozdnyakov/chromium-crosswalk,dednal/chromium.src,fujunwei/chromium-crosswalk,ltilve/chromium,Just-D/chromium-1,Fireblend/chromium-crosswalk,dushu1203/chromium.src,littlstar/chromium.src,timopulkkinen/BubbleFish,TheTypoMaster/chromium-crosswalk,Pluto-tv/chromium-crosswalk,hujiajie/pa-chromium,Chilledheart/chromium,jaruba/chromium.src,Fireblend/chromium-crosswalk,ltilve/chromium,junmin-zhu/chromium-rivertrail,chuan9/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,hujiajie/pa-chromium,mohamed--abdel-maksoud/chromium.src,hujiajie/pa-chromium,junmin-zhu/chromium-rivertrail,hgl888/chromium-crosswalk-efl,patrickm/chromium.src,jaruba/chromium.src,krieger-od/nwjs_chromium.src,M4sse/chromium.src,mohamed--abdel-maksoud/chromium.src,hgl888/chromium-crosswalk-efl,krieger-od/nwjs_chromium.src,markYoungH/chromium.src,dednal/chromium.src,ltilve/chromium,pozdnyakov/chromium-crosswalk,zcbenz/cefode-chromium,littlstar/chromium.src,Chilledheart/chromium,mohamed--abdel-maksoud/chromium.src,PeterWangIntel/chromium-crosswalk,junmin-zhu/chromium-rivertrail,Fireblend/chromium-crosswalk,fujunwei/chromium-crosswalk,zcbenz/cefode-chromium