OLD | NEW |
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 OwnPtr<DatabaseCallback> m_creationCallback; | 95 OwnPtr<DatabaseCallback> m_creationCallback; |
96 }; | 96 }; |
97 | 97 |
98 DatabaseContext* DatabaseManager::existingDatabaseContextFor(ExecutionContext* c
ontext) | 98 DatabaseContext* DatabaseManager::existingDatabaseContextFor(ExecutionContext* c
ontext) |
99 { | 99 { |
100 MutexLocker locker(m_contextMapLock); | 100 MutexLocker locker(m_contextMapLock); |
101 | 101 |
102 ASSERT(m_databaseContextRegisteredCount >= 0); | 102 ASSERT(m_databaseContextRegisteredCount >= 0); |
103 ASSERT(m_databaseContextInstanceCount >= 0); | 103 ASSERT(m_databaseContextInstanceCount >= 0); |
104 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); | 104 ASSERT(m_databaseContextRegisteredCount <= m_databaseContextInstanceCount); |
105 | 105 #if ENABLE(OILPAN) |
| 106 const Persistent<DatabaseContext>* databaseContext = m_contextMap.get(contex
t); |
| 107 return databaseContext ? databaseContext->get() : 0; |
| 108 #else |
106 return m_contextMap.get(context); | 109 return m_contextMap.get(context); |
| 110 #endif |
107 } | 111 } |
108 | 112 |
109 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context) | 113 DatabaseContext* DatabaseManager::databaseContextFor(ExecutionContext* context) |
110 { | 114 { |
111 if (DatabaseContext* databaseContext = existingDatabaseContextFor(context)) | 115 if (DatabaseContext* databaseContext = existingDatabaseContextFor(context)) |
112 return databaseContext; | 116 return databaseContext; |
113 // We don't need to hold a reference returned by DatabaseContext::create | 117 // We don't need to hold a reference returned by DatabaseContext::create |
114 // because DatabaseContext::create calls registerDatabaseContext, and the | 118 // because DatabaseContext::create calls registerDatabaseContext, and the |
115 // DatabaseManager holds a reference. | 119 // DatabaseManager holds a reference. |
116 return DatabaseContext::create(context).get(); | 120 return DatabaseContext::create(context).get(); |
117 } | 121 } |
118 | 122 |
119 void DatabaseManager::registerDatabaseContext(DatabaseContext* databaseContext) | 123 void DatabaseManager::registerDatabaseContext(DatabaseContext* databaseContext) |
120 { | 124 { |
121 MutexLocker locker(m_contextMapLock); | 125 MutexLocker locker(m_contextMapLock); |
122 ExecutionContext* context = databaseContext->executionContext(); | 126 ExecutionContext* context = databaseContext->executionContext(); |
| 127 #if ENABLE(OILPAN) |
| 128 m_contextMap.set(context, adoptPtr(new Persistent<DatabaseContext>(databaseC
ontext))); |
| 129 #else |
123 m_contextMap.set(context, databaseContext); | 130 m_contextMap.set(context, databaseContext); |
| 131 #endif |
124 #if !ASSERT_DISABLED | 132 #if !ASSERT_DISABLED |
125 m_databaseContextRegisteredCount++; | 133 m_databaseContextRegisteredCount++; |
126 #endif | 134 #endif |
127 } | 135 } |
128 | 136 |
129 void DatabaseManager::unregisterDatabaseContext(DatabaseContext* databaseContext
) | 137 void DatabaseManager::unregisterDatabaseContext(DatabaseContext* databaseContext
) |
130 { | 138 { |
131 MutexLocker locker(m_contextMapLock); | 139 MutexLocker locker(m_contextMapLock); |
132 ExecutionContext* context = databaseContext->executionContext(); | 140 ExecutionContext* context = databaseContext->executionContext(); |
133 ASSERT(m_contextMap.get(context)); | 141 ASSERT(m_contextMap.get(context)); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 { | 278 { |
271 m_server->interruptAllDatabasesForContext(databaseContext->backend()); | 279 m_server->interruptAllDatabasesForContext(databaseContext->backend()); |
272 } | 280 } |
273 | 281 |
274 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m
essage) | 282 void DatabaseManager::logErrorMessage(ExecutionContext* context, const String& m
essage) |
275 { | 283 { |
276 context->addConsoleMessage(StorageMessageSource, ErrorMessageLevel, message)
; | 284 context->addConsoleMessage(StorageMessageSource, ErrorMessageLevel, message)
; |
277 } | 285 } |
278 | 286 |
279 } // namespace WebCore | 287 } // namespace WebCore |
OLD | NEW |