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

Side by Side Diff: Source/modules/webdatabase/DatabaseThread.cpp

Issue 596083005: DatabaseBackend should not post a task to an already terminated database thread (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/webdatabase/DatabaseThread.h ('k') | Source/platform/TaskSynchronizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void DatabaseThread::requestTermination(TaskSynchronizer *cleanupSync) 84 void DatabaseThread::requestTermination(TaskSynchronizer *cleanupSync)
85 { 85 {
86 MutexLocker lock(m_terminationRequestedMutex); 86 MutexLocker lock(m_terminationRequestedMutex);
87 ASSERT(!m_terminationRequested); 87 ASSERT(!m_terminationRequested);
88 m_terminationRequested = true; 88 m_terminationRequested = true;
89 m_cleanupSync = cleanupSync; 89 m_cleanupSync = cleanupSync;
90 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this); 90 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this);
91 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread , this))); 91 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread , this)));
92 } 92 }
93 93
94 bool DatabaseThread::terminationRequested(TaskSynchronizer* taskSynchronizer) co nst 94 bool DatabaseThread::terminationRequested() const
95 { 95 {
96 #if ENABLE(ASSERT)
97 if (taskSynchronizer)
98 taskSynchronizer->setHasCheckedForTermination();
99 #endif
100
101 MutexLocker lock(m_terminationRequestedMutex); 96 MutexLocker lock(m_terminationRequestedMutex);
102 return m_terminationRequested; 97 return m_terminationRequested;
103 } 98 }
104 99
105 void DatabaseThread::cleanupDatabaseThread() 100 void DatabaseThread::cleanupDatabaseThread()
106 { 101 {
107 WTF_LOG(StorageAPI, "Cleaning up DatabaseThread %p", this); 102 WTF_LOG(StorageAPI, "Cleaning up DatabaseThread %p", this);
108 103
109 // Clean up the list of all pending transactions on this database thread 104 // Clean up the list of all pending transactions on this database thread
110 m_transactionCoordinator->shutdown(); 105 m_transactionCoordinator->shutdown();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 { 145 {
151 ASSERT(isDatabaseThread()); 146 ASSERT(isDatabaseThread());
152 ASSERT(database); 147 ASSERT(database);
153 MutexLocker lock(m_terminationRequestedMutex); 148 MutexLocker lock(m_terminationRequestedMutex);
154 return !m_terminationRequested && m_openDatabaseSet.contains(database); 149 return !m_terminationRequested && m_openDatabaseSet.contains(database);
155 } 150 }
156 151
157 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) 152 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task)
158 { 153 {
159 ASSERT(m_thread); 154 ASSERT(m_thread);
160 ASSERT(!task->hasSynchronizer() || task->hasCheckedForTermination()); 155 ASSERT(!terminationRequested());
161 // WebThread takes ownership of the task. 156 // WebThread takes ownership of the task.
162 m_thread->postTask(task.leakPtr()); 157 m_thread->postTask(task.leakPtr());
163 } 158 }
164 159
165 } // namespace blink 160 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/DatabaseThread.h ('k') | Source/platform/TaskSynchronizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698