| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Google, Inc. All Rights Reserved. | 3 * Copyright (C) 2011 Google, Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // stopDatabases(), we can't clear the m_databaseThread ref till we get to | 176 // stopDatabases(), we can't clear the m_databaseThread ref till we get to |
| 177 // the destructor. This is because the Databases that are managed by | 177 // the destructor. This is because the Databases that are managed by |
| 178 // DatabaseThread still rely on this ref between the context and the thread | 178 // DatabaseThread still rely on this ref between the context and the thread |
| 179 // to execute the task for closing the database. By the time we get to the | 179 // to execute the task for closing the database. By the time we get to the |
| 180 // destructor, we're guaranteed that the databases are destructed (which is | 180 // destructor, we're guaranteed that the databases are destructed (which is |
| 181 // why our ref count is 0 then and we're destructing). Then, the | 181 // why our ref count is 0 then and we're destructing). Then, the |
| 182 // m_databaseThread RefPtr destructor will deref and delete the | 182 // m_databaseThread RefPtr destructor will deref and delete the |
| 183 // DatabaseThread. | 183 // DatabaseThread. |
| 184 | 184 |
| 185 if (databaseThreadAvailable()) { | 185 if (databaseThreadAvailable()) { |
| 186 TaskSynchronizer sync; | |
| 187 m_databaseThread->requestTermination(&sync); | |
| 188 m_hasRequestedTermination = true; | 186 m_hasRequestedTermination = true; |
| 189 sync.waitForTaskCompletion(); | 187 // This blocks until the database thread finishes the cleanup task. |
| 188 m_databaseThread->terminate(); |
| 190 } | 189 } |
| 191 } | 190 } |
| 192 | 191 |
| 193 bool DatabaseContext::allowDatabaseAccess() const | 192 bool DatabaseContext::allowDatabaseAccess() const |
| 194 { | 193 { |
| 195 return toDocument(executionContext())->isActive(); | 194 return toDocument(executionContext())->isActive(); |
| 196 } | 195 } |
| 197 | 196 |
| 198 SecurityOrigin* DatabaseContext::securityOrigin() const | 197 SecurityOrigin* DatabaseContext::securityOrigin() const |
| 199 { | 198 { |
| 200 return executionContext()->securityOrigin(); | 199 return executionContext()->securityOrigin(); |
| 201 } | 200 } |
| 202 | 201 |
| 203 bool DatabaseContext::isContextThread() const | 202 bool DatabaseContext::isContextThread() const |
| 204 { | 203 { |
| 205 return executionContext()->isContextThread(); | 204 return executionContext()->isContextThread(); |
| 206 } | 205 } |
| 207 | 206 |
| 208 } // namespace blink | 207 } // namespace blink |
| OLD | NEW |