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

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

Issue 915703002: Add task location information to ExecutionContext (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 5 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 25 matching lines...) Expand all
36 #include "modules/webdatabase/Database.h" 36 #include "modules/webdatabase/Database.h"
37 #include "modules/webdatabase/DatabaseClient.h" 37 #include "modules/webdatabase/DatabaseClient.h"
38 #include "modules/webdatabase/DatabaseContext.h" 38 #include "modules/webdatabase/DatabaseContext.h"
39 #include "modules/webdatabase/QuotaTracker.h" 39 #include "modules/webdatabase/QuotaTracker.h"
40 #include "modules/webdatabase/sqlite/SQLiteFileSystem.h" 40 #include "modules/webdatabase/sqlite/SQLiteFileSystem.h"
41 #include "platform/weborigin/DatabaseIdentifier.h" 41 #include "platform/weborigin/DatabaseIdentifier.h"
42 #include "platform/weborigin/SecurityOrigin.h" 42 #include "platform/weborigin/SecurityOrigin.h"
43 #include "platform/weborigin/SecurityOriginHash.h" 43 #include "platform/weborigin/SecurityOriginHash.h"
44 #include "public/platform/Platform.h" 44 #include "public/platform/Platform.h"
45 #include "public/platform/WebDatabaseObserver.h" 45 #include "public/platform/WebDatabaseObserver.h"
46 #include "public/platform/WebTraceLocation.h"
46 #include "wtf/Assertions.h" 47 #include "wtf/Assertions.h"
47 #include "wtf/StdLibExtras.h" 48 #include "wtf/StdLibExtras.h"
48 49
49 namespace blink { 50 namespace blink {
50 51
51 static void databaseClosed(Database* database) 52 static void databaseClosed(Database* database)
52 { 53 {
53 if (Platform::current()->databaseObserver()) { 54 if (Platform::current()->databaseObserver()) {
54 Platform::current()->databaseObserver()->databaseClosed( 55 Platform::current()->databaseObserver()->databaseClosed(
55 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin( )), 56 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin( )),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 nameMap->remove(name); 155 nameMap->remove(name);
155 delete databaseSet; 156 delete databaseSet;
156 if (nameMap->isEmpty()) { 157 if (nameMap->isEmpty()) {
157 m_openDatabaseMap->remove(originIdentifier); 158 m_openDatabaseMap->remove(originIdentifier);
158 delete nameMap; 159 delete nameMap;
159 } 160 }
160 } 161 }
161 162
162 ExecutionContext* executionContext = database->databaseContext()->executionC ontext(); 163 ExecutionContext* executionContext = database->databaseContext()->executionC ontext();
163 if (!executionContext->isContextThread()) 164 if (!executionContext->isContextThread())
164 executionContext->postTask(NotifyDatabaseObserverOnCloseTask::create(dat abase)); 165 executionContext->postTask(FROM_HERE, NotifyDatabaseObserverOnCloseTask: :create(database));
165 else 166 else
166 databaseClosed(database); 167 databaseClosed(database);
167 } 168 }
168 169
169 void DatabaseTracker::prepareToOpenDatabase(Database* database) 170 void DatabaseTracker::prepareToOpenDatabase(Database* database)
170 { 171 {
171 ASSERT(database->databaseContext()->executionContext()->isContextThread()); 172 ASSERT(database->databaseContext()->executionContext()->isContextThread());
172 if (Platform::current()->databaseObserver()) { 173 if (Platform::current()->databaseObserver()) {
173 Platform::current()->databaseObserver()->databaseOpened( 174 Platform::current()->databaseObserver()->databaseOpened(
174 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin( )), 175 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin( )),
175 database->stringIdentifier(), 176 database->stringIdentifier(),
176 database->displayName(), 177 database->displayName(),
177 database->estimatedSize()); 178 database->estimatedSize());
178 } 179 }
179 } 180 }
180 181
181 void DatabaseTracker::failedToOpenDatabase(Database* database) 182 void DatabaseTracker::failedToOpenDatabase(Database* database)
182 { 183 {
183 ExecutionContext* executionContext = database->databaseContext()->executionC ontext(); 184 ExecutionContext* executionContext = database->databaseContext()->executionC ontext();
184 if (!executionContext->isContextThread()) 185 if (!executionContext->isContextThread())
185 executionContext->postTask(NotifyDatabaseObserverOnCloseTask::create(dat abase)); 186 executionContext->postTask(FROM_HERE, NotifyDatabaseObserverOnCloseTask: :create(database));
186 else 187 else
187 databaseClosed(database); 188 databaseClosed(database);
188 } 189 }
189 190
190 unsigned long long DatabaseTracker::getMaxSizeForDatabase(const Database* databa se) 191 unsigned long long DatabaseTracker::getMaxSizeForDatabase(const Database* databa se)
191 { 192 {
192 unsigned long long spaceAvailable = 0; 193 unsigned long long spaceAvailable = 0;
193 unsigned long long databaseSize = 0; 194 unsigned long long databaseSize = 0;
194 QuotaTracker::instance().getDatabaseSizeAndSpaceAvailableToOrigin( 195 QuotaTracker::instance().getDatabaseSizeAndSpaceAvailableToOrigin(
195 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin()), 196 createDatabaseIdentifierFromSecurityOrigin(database->securityOrigin()),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier); 232 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier);
232 if (!nameMap) 233 if (!nameMap)
233 return; 234 return;
234 235
235 DatabaseSet* databaseSet = nameMap->get(name); 236 DatabaseSet* databaseSet = nameMap->get(name);
236 if (!databaseSet) 237 if (!databaseSet)
237 return; 238 return;
238 239
239 // We have to call closeImmediately() on the context thread. 240 // We have to call closeImmediately() on the context thread.
240 for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end (); ++it) 241 for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end (); ++it)
241 (*it)->databaseContext()->executionContext()->postTask(CloseOneDatabaseI mmediatelyTask::create(originIdentifier, name, *it)); 242 (*it)->databaseContext()->executionContext()->postTask(FROM_HERE, CloseO neDatabaseImmediatelyTask::create(originIdentifier, name, *it));
242 } 243 }
243 244
244 void DatabaseTracker::closeOneDatabaseImmediately(const String& originIdentifier , const String& name, Database* database) 245 void DatabaseTracker::closeOneDatabaseImmediately(const String& originIdentifier , const String& name, Database* database)
245 { 246 {
246 // First we have to confirm the 'database' is still in our collection. 247 // First we have to confirm the 'database' is still in our collection.
247 { 248 {
248 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); 249 MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
249 if (!m_openDatabaseMap) 250 if (!m_openDatabaseMap)
250 return; 251 return;
251 252
252 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier); 253 DatabaseNameMap* nameMap = m_openDatabaseMap->get(originIdentifier);
253 if (!nameMap) 254 if (!nameMap)
254 return; 255 return;
255 256
256 DatabaseSet* databaseSet = nameMap->get(name); 257 DatabaseSet* databaseSet = nameMap->get(name);
257 if (!databaseSet) 258 if (!databaseSet)
258 return; 259 return;
259 260
260 DatabaseSet::iterator found = databaseSet->find(database); 261 DatabaseSet::iterator found = databaseSet->find(database);
261 if (found == databaseSet->end()) 262 if (found == databaseSet->end())
262 return; 263 return;
263 } 264 }
264 265
265 // And we have to call closeImmediately() without our collection lock being held. 266 // And we have to call closeImmediately() without our collection lock being held.
266 database->closeImmediately(); 267 database->closeImmediately();
267 } 268 }
268 269
269 } // namespace blink 270 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/DatabaseManager.cpp ('k') | Source/modules/webdatabase/SQLTransactionClient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698