diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 00:08:41 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-26 00:08:41 +0000 |
commit | d77ca3edc4b240592b94d3287047386b3ab5470c (patch) | |
tree | 430ea8ddb302741b992c3382215add8b80899ab8 /chrome/test/automation/automation_handle_tracker.h | |
parent | e59a1c4503496f843391641dbb947043dec2a466 (diff) | |
download | chromium_src-d77ca3edc4b240592b94d3287047386b3ab5470c.zip chromium_src-d77ca3edc4b240592b94d3287047386b3ab5470c.tar.gz chromium_src-d77ca3edc4b240592b94d3287047386b3ab5470c.tar.bz2 |
Fix the ui test crashes on Linux. There is a race condition between the channel getting destroyed
and it being referenced in the background thread.
Fix is to use the underlying IPC::Channel pointer passed to the message filter when the
filter gets Added to send and receive messages. This ensures that the SyncChannel is not used across
threads.
Review URL: http://codereview.chromium.org/661109
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40076 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation/automation_handle_tracker.h')
-rw-r--r-- | chrome/test/automation/automation_handle_tracker.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/chrome/test/automation/automation_handle_tracker.h b/chrome/test/automation/automation_handle_tracker.h index 1117710..fc33600 100644 --- a/chrome/test/automation/automation_handle_tracker.h +++ b/chrome/test/automation/automation_handle_tracker.h @@ -13,6 +13,7 @@ #include "base/basictypes.h" #include "base/lock.h" #include "base/ref_counted.h" +#include "ipc/ipc_channel.h" // This represents a value that the app's AutomationProvider returns // when asked for a resource (like a window or tab). @@ -30,7 +31,11 @@ class AutomationResourceProxy // Marks this proxy object as no longer valid; this generally means // that the corresponding resource on the app side is gone. - void Invalidate() { is_valid_ = false; } + void Invalidate() { + is_valid_ = false; + tracker_ = NULL; + } + bool is_valid() const { return is_valid_; } // Returns the handle that the app has generated to refer to this resource. @@ -44,12 +49,6 @@ class AutomationResourceProxy AutomationHandle handle_; - // Called by the tracker when it is being destroyed so we know not to call - // it back. - void TrackerGone() { - tracker_ = NULL; - } - // Not owned by us, owned by the AutomationProxy object. May be NULL if the // tracker has been destroyed (and hence the object is invalid). AutomationHandleTracker* tracker_; @@ -74,8 +73,7 @@ class AutomationResourceProxy // discard the handle. class AutomationHandleTracker { public: - explicit AutomationHandleTracker(AutomationMessageSender* sender) - : sender_(sender) {} + explicit AutomationHandleTracker() : channel_(NULL) {} ~AutomationHandleTracker(); // Adds the specified proxy object to the tracker. @@ -94,6 +92,11 @@ class AutomationHandleTracker { void InvalidateHandle(AutomationHandle handle); AutomationResourceProxy* GetResource(AutomationHandle handle); + + void put_channel(IPC::Channel* channel) { + channel_ = channel; + } + private: typedef std::map<AutomationHandle, scoped_refptr<AutomationResourceProxy> > @@ -102,8 +105,8 @@ class AutomationHandleTracker { HandleToObjectMap handle_to_object_; - AutomationMessageSender* sender_; Lock map_lock_; + IPC::Channel* channel_; DISALLOW_EVIL_CONSTRUCTORS(AutomationHandleTracker); }; |