summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_delegate.h
diff options
context:
space:
mode:
authorstoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-11 18:06:00 +0000
committerstoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-11 18:06:00 +0000
commit3148c0ae4462e01f4b830b8d2150dcd7fee2cb3b (patch)
treeb475d693512495f0e2209d1f85a852beb45dc1c5 /chrome_frame/chrome_frame_delegate.h
parentb438c4a50990c32e11e8b9a4d806c8a7bc2b8746 (diff)
downloadchromium_src-3148c0ae4462e01f4b830b8d2150dcd7fee2cb3b.zip
chromium_src-3148c0ae4462e01f4b830b8d2150dcd7fee2cb3b.tar.gz
chromium_src-3148c0ae4462e01f4b830b8d2150dcd7fee2cb3b.tar.bz2
AddRef ChromeFrameAutomationClient as long as the supporting window exists.
Crash was due the final Release() called from inside message handler. Additionally prevent invoking member functions of invalid/old chrome_frame_delegate_. Still have a race acessing url_fetcher_ though. BUG=35556 Review URL: http://codereview.chromium.org/825005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41290 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_frame_delegate.h')
-rw-r--r--chrome_frame/chrome_frame_delegate.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h
index a235bcd..63409b9 100644
--- a/chrome_frame/chrome_frame_delegate.h
+++ b/chrome_frame/chrome_frame_delegate.h
@@ -145,7 +145,6 @@ template <class T> class TaskMarshallerThroughWindowsMessages
}
}
-
protected:
~TaskMarshallerThroughWindowsMessages() {
DeleteAllPendingTasks();
@@ -171,9 +170,11 @@ template <class T> class TaskMarshallerThroughWindowsMessages
inline LRESULT ExecuteTask(UINT, WPARAM wparam, LPARAM,
BOOL& handled) { // NOLINT
Task* task = reinterpret_cast<Task*>(wparam);
- PopTask(task);
- task->Run();
- delete task;
+ if (task && PopTask(task)) {
+ task->Run();
+ delete task;
+ }
+
T* this_ptr = static_cast<T*>(this);
this_ptr->Release();
return 0;
@@ -184,10 +185,17 @@ template <class T> class TaskMarshallerThroughWindowsMessages
pending_tasks_.push(task);
}
- inline void PopTask(Task* task) {
+ // If the given task is front of the queue, removes the task and returns true,
+ // otherwise we assume this is an already destroyed task (but Window message
+ // had remained in the thread queue).
+ inline bool PopTask(Task* task) {
AutoLock lock(lock_);
- DCHECK_EQ(task, pending_tasks_.front());
- pending_tasks_.pop();
+ if (task == pending_tasks_.front()) {
+ pending_tasks_.pop();
+ return true;
+ }
+
+ return false;
}
Lock lock_;