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

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

Issue 1766903002: Remove ExecutionContextTask subclasses that have task names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Kuroneko_EC7_Document
Patch Set: Add a comment Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/StringCallback.cpp ('k') | no next file » | 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) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 : m_databaseContextRegisteredCount(0) 68 : m_databaseContextRegisteredCount(0)
69 , m_databaseContextInstanceCount(0) 69 , m_databaseContextInstanceCount(0)
70 #endif 70 #endif
71 { 71 {
72 } 72 }
73 73
74 DatabaseManager::~DatabaseManager() 74 DatabaseManager::~DatabaseManager()
75 { 75 {
76 } 76 }
77 77
78 class DatabaseCreationCallbackTask final : public ExecutionContextTask { 78 // This is just for ignoring DatabaseCallback::handleEvent()'s return value.
79 public: 79 static void databaseCallbackHandleEvent(DatabaseCallback* callback, Database* da tabase)
80 static std::unique_ptr<DatabaseCreationCallbackTask> create(Database* databa se, DatabaseCallback* creationCallback) 80 {
81 { 81 callback->handleEvent(database);
82 return wrapUnique(new DatabaseCreationCallbackTask(database, creationCal lback)); 82 }
83 }
84
85 void performTask(ExecutionContext*) override
86 {
87 m_creationCallback->handleEvent(m_database.get());
88 }
89
90 private:
91 DatabaseCreationCallbackTask(Database* database, DatabaseCallback* callback)
92 : m_database(database)
93 , m_creationCallback(callback)
94 {
95 }
96
97 Persistent<Database> m_database;
98 Persistent<DatabaseCallback> m_creationCallback;
99 };
100 83
101 DatabaseContext* DatabaseManager::existingDatabaseContextFor(ExecutionContext* c ontext) 84 DatabaseContext* DatabaseManager::existingDatabaseContextFor(ExecutionContext* c ontext)
102 { 85 {
103 ASSERT(m_databaseContextRegisteredCount >= 0); 86 ASSERT(m_databaseContextRegisteredCount >= 0);
104 ASSERT(m_databaseContextInstanceCount >= 0); 87 ASSERT(m_databaseContextInstanceCount >= 0);
105 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); 88 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount);
106 return m_contextMap.get(context); 89 return m_contextMap.get(context);
107 } 90 }
108 91
109 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context) 92 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 Database* database = openDatabaseInternal(context, name, 190 Database* database = openDatabaseInternal(context, name,
208 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er ror, errorMessage); 191 expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, er ror, errorMessage);
209 if (!database) 192 if (!database)
210 return nullptr; 193 return nullptr;
211 194
212 databaseContextFor(context)->setHasOpenDatabases(); 195 databaseContextFor(context)->setHasOpenDatabases();
213 DatabaseClient::from(context)->didOpenDatabase(database, context->getSecurit yOrigin()->host(), name, expectedVersion); 196 DatabaseClient::from(context)->didOpenDatabase(database, context->getSecurit yOrigin()->host(), name, expectedVersion);
214 197
215 if (database->isNew() && creationCallback) { 198 if (database->isNew() && creationCallback) {
216 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas e %p\n", database); 199 WTF_LOG(StorageAPI, "Scheduling DatabaseCreationCallbackTask for databas e %p\n", database);
217 database->getExecutionContext()->postTask(BLINK_FROM_HERE, DatabaseCreat ionCallbackTask::create(database, creationCallback), "openDatabase"); 200 database->getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThr eadTask(&databaseCallbackHandleEvent, wrapPersistent(creationCallback), wrapPers istent(database)), "openDatabase");
218 } 201 }
219 202
220 ASSERT(database); 203 ASSERT(database);
221 return database; 204 return database;
222 } 205 }
223 206
224 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String & name, bool createIfDoesNotExist) 207 String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String & name, bool createIfDoesNotExist)
225 { 208 {
226 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf DoesNotExist); 209 return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIf DoesNotExist);
227 } 210 }
228 211
229 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m essage) 212 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m essage)
230 { 213 {
231 context->addConsoleMessage(ConsoleMessage::create(StorageMessageSource, Erro rMessageLevel, message)); 214 context->addConsoleMessage(ConsoleMessage::create(StorageMessageSource, Erro rMessageLevel, message));
232 } 215 }
233 216
234 } // namespace blink 217 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StringCallback.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698