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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/Database.cpp

Issue 2288983004: Merge TaskSynchronizer into WaitableEvent. (Closed)
Patch Set: fix Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 30 matching lines...) Expand all
41 #include "modules/webdatabase/SQLError.h" 41 #include "modules/webdatabase/SQLError.h"
42 #include "modules/webdatabase/SQLTransaction.h" 42 #include "modules/webdatabase/SQLTransaction.h"
43 #include "modules/webdatabase/SQLTransactionBackend.h" 43 #include "modules/webdatabase/SQLTransactionBackend.h"
44 #include "modules/webdatabase/SQLTransactionCallback.h" 44 #include "modules/webdatabase/SQLTransactionCallback.h"
45 #include "modules/webdatabase/SQLTransactionClient.h" 45 #include "modules/webdatabase/SQLTransactionClient.h"
46 #include "modules/webdatabase/SQLTransactionCoordinator.h" 46 #include "modules/webdatabase/SQLTransactionCoordinator.h"
47 #include "modules/webdatabase/SQLTransactionErrorCallback.h" 47 #include "modules/webdatabase/SQLTransactionErrorCallback.h"
48 #include "modules/webdatabase/StorageLog.h" 48 #include "modules/webdatabase/StorageLog.h"
49 #include "modules/webdatabase/sqlite/SQLiteStatement.h" 49 #include "modules/webdatabase/sqlite/SQLiteStatement.h"
50 #include "modules/webdatabase/sqlite/SQLiteTransaction.h" 50 #include "modules/webdatabase/sqlite/SQLiteTransaction.h"
51 #include "platform/WaitableEvent.h"
51 #include "platform/heap/SafePoint.h" 52 #include "platform/heap/SafePoint.h"
52 #include "public/platform/Platform.h" 53 #include "public/platform/Platform.h"
53 #include "public/platform/WebDatabaseObserver.h" 54 #include "public/platform/WebDatabaseObserver.h"
54 #include "public/platform/WebSecurityOrigin.h" 55 #include "public/platform/WebSecurityOrigin.h"
55 #include "wtf/Atomics.h" 56 #include "wtf/Atomics.h"
56 #include "wtf/CurrentTime.h" 57 #include "wtf/CurrentTime.h"
57 #include <memory> 58 #include <memory>
58 59
59 // Registering "opened" databases with the DatabaseTracker 60 // Registering "opened" databases with the DatabaseTracker
60 // ======================================================= 61 // =======================================================
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 253
253 DEFINE_TRACE(Database) 254 DEFINE_TRACE(Database)
254 { 255 {
255 visitor->trace(m_databaseContext); 256 visitor->trace(m_databaseContext);
256 visitor->trace(m_sqliteDatabase); 257 visitor->trace(m_sqliteDatabase);
257 visitor->trace(m_databaseAuthorizer); 258 visitor->trace(m_databaseAuthorizer);
258 } 259 }
259 260
260 bool Database::openAndVerifyVersion(bool setVersionInNewDatabase, DatabaseError& error, String& errorMessage) 261 bool Database::openAndVerifyVersion(bool setVersionInNewDatabase, DatabaseError& error, String& errorMessage)
261 { 262 {
262 TaskSynchronizer synchronizer; 263 WaitableEvent event;
263 if (!getDatabaseContext()->databaseThreadAvailable()) 264 if (!getDatabaseContext()->databaseThreadAvailable())
264 return false; 265 return false;
265 266
266 DatabaseTracker::tracker().prepareToOpenDatabase(this); 267 DatabaseTracker::tracker().prepareToOpenDatabase(this);
267 bool success = false; 268 bool success = false;
268 std::unique_ptr<DatabaseOpenTask> task = DatabaseOpenTask::create(this, setV ersionInNewDatabase, &synchronizer, error, errorMessage, success); 269 std::unique_ptr<DatabaseOpenTask> task = DatabaseOpenTask::create(this, setV ersionInNewDatabase, &event, error, errorMessage, success);
269 getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); 270 getDatabaseContext()->databaseThread()->scheduleTask(std::move(task));
270 synchronizer.waitForTaskCompletion(); 271 event.wait();
271 272
272 return success; 273 return success;
273 } 274 }
274 275
275 void Database::close() 276 void Database::close()
276 { 277 {
277 ASSERT(getDatabaseContext()->databaseThread()); 278 ASSERT(getDatabaseContext()->databaseThread());
278 ASSERT(getDatabaseContext()->databaseThread()->isDatabaseThread()); 279 ASSERT(getDatabaseContext()->databaseThread()->isDatabaseThread());
279 280
280 { 281 {
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 877
877 return tableNames; 878 return tableNames;
878 } 879 }
879 880
880 Vector<String> Database::tableNames() 881 Vector<String> Database::tableNames()
881 { 882 {
882 // FIXME: Not using isolatedCopy on these strings looks ok since threads 883 // FIXME: Not using isolatedCopy on these strings looks ok since threads
883 // take strict turns in dealing with them. However, if the code changes, 884 // take strict turns in dealing with them. However, if the code changes,
884 // this may not be true anymore. 885 // this may not be true anymore.
885 Vector<String> result; 886 Vector<String> result;
886 TaskSynchronizer synchronizer; 887 WaitableEvent event;
887 if (!getDatabaseContext()->databaseThreadAvailable()) 888 if (!getDatabaseContext()->databaseThreadAvailable())
888 return result; 889 return result;
889 890
890 std::unique_ptr<DatabaseTableNamesTask> task = DatabaseTableNamesTask::creat e(this, &synchronizer, result); 891 std::unique_ptr<DatabaseTableNamesTask> task = DatabaseTableNamesTask::creat e(this, &event, result);
891 getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); 892 getDatabaseContext()->databaseThread()->scheduleTask(std::move(task));
892 synchronizer.waitForTaskCompletion(); 893 event.wait();
893 894
894 return result; 895 return result;
895 } 896 }
896 897
897 SecurityOrigin* Database::getSecurityOrigin() const 898 SecurityOrigin* Database::getSecurityOrigin() const
898 { 899 {
899 if (getExecutionContext()->isContextThread()) 900 if (getExecutionContext()->isContextThread())
900 return m_contextThreadSecurityOrigin.get(); 901 return m_contextThreadSecurityOrigin.get();
901 if (getDatabaseContext()->databaseThread()->isDatabaseThread()) 902 if (getDatabaseContext()->databaseThread()->isDatabaseThread())
902 return m_databaseThreadSecurityOrigin.get(); 903 return m_databaseThreadSecurityOrigin.get();
903 return 0; 904 return 0;
904 } 905 }
905 906
906 bool Database::opened() 907 bool Database::opened()
907 { 908 {
908 return static_cast<bool>(acquireLoad(&m_opened)); 909 return static_cast<bool>(acquireLoad(&m_opened));
909 } 910 }
910 911
911 } // namespace blink 912 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698