| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 #include "modules/webdatabase/DatabaseThread.h" | 29 #include "modules/webdatabase/DatabaseThread.h" |
| 30 | 30 |
| 31 #include "modules/webdatabase/Database.h" | 31 #include "modules/webdatabase/Database.h" |
| 32 #include "modules/webdatabase/DatabaseTask.h" | 32 #include "modules/webdatabase/DatabaseTask.h" |
| 33 #include "modules/webdatabase/SQLTransactionClient.h" | 33 #include "modules/webdatabase/SQLTransactionClient.h" |
| 34 #include "modules/webdatabase/SQLTransactionCoordinator.h" | 34 #include "modules/webdatabase/SQLTransactionCoordinator.h" |
| 35 #include "platform/Logging.h" | 35 #include "platform/Logging.h" |
| 36 #include "platform/ThreadSafeFunctional.h" | 36 #include "platform/ThreadSafeFunctional.h" |
| 37 #include "platform/WebThreadSupportingGC.h" | 37 #include "platform/WebThreadSupportingGC.h" |
| 38 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 39 #include "wtf/PtrUtil.h" |
| 40 #include <memory> |
| 39 | 41 |
| 40 namespace blink { | 42 namespace blink { |
| 41 | 43 |
| 42 DatabaseThread::DatabaseThread() | 44 DatabaseThread::DatabaseThread() |
| 43 : m_transactionClient(adoptPtr(new SQLTransactionClient())) | 45 : m_transactionClient(wrapUnique(new SQLTransactionClient())) |
| 44 , m_cleanupSync(nullptr) | 46 , m_cleanupSync(nullptr) |
| 45 , m_terminationRequested(false) | 47 , m_terminationRequested(false) |
| 46 { | 48 { |
| 47 DCHECK(isMainThread()); | 49 DCHECK(isMainThread()); |
| 48 } | 50 } |
| 49 | 51 |
| 50 DatabaseThread::~DatabaseThread() | 52 DatabaseThread::~DatabaseThread() |
| 51 { | 53 { |
| 52 ASSERT(m_openDatabaseSet.isEmpty()); | 54 ASSERT(m_openDatabaseSet.isEmpty()); |
| 53 ASSERT(!m_thread); | 55 ASSERT(!m_thread); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 return !m_terminationRequested && m_openDatabaseSet.contains(database); | 155 return !m_terminationRequested && m_openDatabaseSet.contains(database); |
| 154 } | 156 } |
| 155 | 157 |
| 156 bool DatabaseThread::isDatabaseThread() const | 158 bool DatabaseThread::isDatabaseThread() const |
| 157 { | 159 { |
| 158 // This function is called only from the main thread or the database | 160 // This function is called only from the main thread or the database |
| 159 // thread. If we are not in the main thread, we are in the database thread. | 161 // thread. If we are not in the main thread, we are in the database thread. |
| 160 return !isMainThread(); | 162 return !isMainThread(); |
| 161 } | 163 } |
| 162 | 164 |
| 163 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) | 165 void DatabaseThread::scheduleTask(std::unique_ptr<DatabaseTask> task) |
| 164 { | 166 { |
| 165 ASSERT(m_thread); | 167 ASSERT(m_thread); |
| 166 #if ENABLE(ASSERT) | 168 #if ENABLE(ASSERT) |
| 167 { | 169 { |
| 168 MutexLocker lock(m_terminationRequestedMutex); | 170 MutexLocker lock(m_terminationRequestedMutex); |
| 169 ASSERT(!m_terminationRequested); | 171 ASSERT(!m_terminationRequested); |
| 170 } | 172 } |
| 171 #endif | 173 #endif |
| 172 // WebThread takes ownership of the task. | 174 // WebThread takes ownership of the task. |
| 173 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseTask::run, std::
move(task))); | 175 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseTask::run, std::
move(task))); |
| 174 } | 176 } |
| 175 | 177 |
| 176 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |