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

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

Issue 2640163004: Replace ENABLE(ASSERT) with DCHECK_IS_ON(). (Closed)
Patch Set: Created 3 years, 11 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) 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 void DatabaseManager::terminateDatabaseThread() { 57 void DatabaseManager::terminateDatabaseThread() {
58 DCHECK(isMainThread()); 58 DCHECK(isMainThread());
59 if (!s_databaseManager) 59 if (!s_databaseManager)
60 return; 60 return;
61 for (const Member<DatabaseContext>& context : 61 for (const Member<DatabaseContext>& context :
62 s_databaseManager->m_contextMap.values()) 62 s_databaseManager->m_contextMap.values())
63 context->stopDatabases(); 63 context->stopDatabases();
64 } 64 }
65 65
66 DatabaseManager::DatabaseManager() 66 DatabaseManager::DatabaseManager()
67 #if ENABLE(ASSERT)
68 : m_databaseContextRegisteredCount(0),
69 m_databaseContextInstanceCount(0)
70 #endif
71 { 67 {
72 } 68 }
73 69
74 DatabaseManager::~DatabaseManager() {} 70 DatabaseManager::~DatabaseManager() {}
75 71
76 // This is just for ignoring DatabaseCallback::handleEvent()'s return value. 72 // This is just for ignoring DatabaseCallback::handleEvent()'s return value.
77 static void databaseCallbackHandleEvent(DatabaseCallback* callback, 73 static void databaseCallbackHandleEvent(DatabaseCallback* callback,
78 Database* database) { 74 Database* database) {
79 callback->handleEvent(database); 75 callback->handleEvent(database);
80 } 76 }
(...skipping 10 matching lines...) Expand all
91 ExecutionContext* context) { 87 ExecutionContext* context) {
92 if (DatabaseContext* databaseContext = existingDatabaseContextFor(context)) 88 if (DatabaseContext* databaseContext = existingDatabaseContextFor(context))
93 return databaseContext; 89 return databaseContext;
94 return DatabaseContext::create(context); 90 return DatabaseContext::create(context);
95 } 91 }
96 92
97 void DatabaseManager::registerDatabaseContext( 93 void DatabaseManager::registerDatabaseContext(
98 DatabaseContext* databaseContext) { 94 DatabaseContext* databaseContext) {
99 ExecutionContext* context = databaseContext->getExecutionContext(); 95 ExecutionContext* context = databaseContext->getExecutionContext();
100 m_contextMap.set(context, databaseContext); 96 m_contextMap.set(context, databaseContext);
101 #if ENABLE(ASSERT) 97 #if DCHECK_IS_ON()
102 m_databaseContextRegisteredCount++; 98 m_databaseContextRegisteredCount++;
103 #endif 99 #endif
104 } 100 }
105 101
106 void DatabaseManager::unregisterDatabaseContext( 102 void DatabaseManager::unregisterDatabaseContext(
107 DatabaseContext* databaseContext) { 103 DatabaseContext* databaseContext) {
108 ExecutionContext* context = databaseContext->getExecutionContext(); 104 ExecutionContext* context = databaseContext->getExecutionContext();
109 ASSERT(m_contextMap.get(context)); 105 ASSERT(m_contextMap.get(context));
110 #if ENABLE(ASSERT) 106 #if DCHECK_IS_ON()
111 m_databaseContextRegisteredCount--; 107 m_databaseContextRegisteredCount--;
112 #endif 108 #endif
113 m_contextMap.remove(context); 109 m_contextMap.remove(context);
114 } 110 }
115 111
116 #if ENABLE(ASSERT) 112 #if DCHECK_IS_ON()
117 void DatabaseManager::didConstructDatabaseContext() { 113 void DatabaseManager::didConstructDatabaseContext() {
118 m_databaseContextInstanceCount++; 114 m_databaseContextInstanceCount++;
119 } 115 }
120 116
121 void DatabaseManager::didDestructDatabaseContext() { 117 void DatabaseManager::didDestructDatabaseContext() {
122 m_databaseContextInstanceCount--; 118 m_databaseContextInstanceCount--;
123 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); 119 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount);
124 } 120 }
125 #endif 121 #endif
126 122
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 createIfDoesNotExist); 224 createIfDoesNotExist);
229 } 225 }
230 226
231 void DatabaseManager::logErrorMessage(ExecutionContext* context, 227 void DatabaseManager::logErrorMessage(ExecutionContext* context,
232 const String& message) { 228 const String& message) {
233 context->addConsoleMessage( 229 context->addConsoleMessage(
234 ConsoleMessage::create(StorageMessageSource, ErrorMessageLevel, message)); 230 ConsoleMessage::create(StorageMessageSource, ErrorMessageLevel, message));
235 } 231 }
236 232
237 } // namespace blink 233 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698