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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 class SecurityOrigin; | 48 class SecurityOrigin; |
49 class ExecutionContext; | 49 class ExecutionContext; |
50 | 50 |
51 typedef int ExceptionCode; | 51 typedef int ExceptionCode; |
52 | 52 |
53 class DatabaseManager { | 53 class DatabaseManager { |
54 WTF_MAKE_NONCOPYABLE(DatabaseManager); WTF_MAKE_FAST_ALLOCATED; | 54 WTF_MAKE_NONCOPYABLE(DatabaseManager); WTF_MAKE_FAST_ALLOCATED; |
55 public: | 55 public: |
56 static DatabaseManager& manager(); | 56 static DatabaseManager& manager(); |
57 | 57 |
58 // This gets a DatabaseContext for the specified ExecutionContext. | |
59 // If one doesn't already exist, it will create a new one. | |
60 PassRefPtr<DatabaseContext> databaseContextFor(ExecutionContext*); | |
61 | |
62 // These 2 methods are for DatabaseContext (un)registration, and should only | 58 // These 2 methods are for DatabaseContext (un)registration, and should only |
63 // be called by the DatabaseContext constructor and destructor. | 59 // be called by the DatabaseContext constructor and destructor. |
64 void registerDatabaseContext(DatabaseContext*); | 60 void registerDatabaseContext(DatabaseContext*); |
65 void unregisterDatabaseContext(DatabaseContext*); | 61 void unregisterDatabaseContext(DatabaseContext*); |
66 | 62 |
67 #if !ASSERT_DISABLED | 63 #if !ASSERT_DISABLED |
68 void didConstructDatabaseContext(); | 64 void didConstructDatabaseContext(); |
69 void didDestructDatabaseContext(); | 65 void didDestructDatabaseContext(); |
70 #else | 66 #else |
71 void didConstructDatabaseContext() { } | 67 void didConstructDatabaseContext() { } |
72 void didDestructDatabaseContext() { } | 68 void didDestructDatabaseContext() { } |
73 #endif | 69 #endif |
74 | 70 |
75 static void throwExceptionForDatabaseError(DatabaseError, const String& erro
rMessage, ExceptionState&); | 71 static void throwExceptionForDatabaseError(DatabaseError, const String& erro
rMessage, ExceptionState&); |
76 | 72 |
77 PassRefPtrWillBeRawPtr<Database> openDatabase(ExecutionContext*, const Strin
g& name, const String& expectedVersion, const String& displayName, unsigned long
estimatedSize, PassOwnPtr<DatabaseCallback>, DatabaseError&, String& errorMessa
ge); | 73 PassRefPtrWillBeRawPtr<Database> openDatabase(ExecutionContext*, const Strin
g& name, const String& expectedVersion, const String& displayName, unsigned long
estimatedSize, PassOwnPtr<DatabaseCallback>, DatabaseError&, String& errorMessa
ge); |
78 PassRefPtrWillBeRawPtr<DatabaseSync> openDatabaseSync(ExecutionContext*, con
st String& name, const String& expectedVersion, const String& displayName, unsig
ned long estimatedSize, PassOwnPtr<DatabaseCallback>, DatabaseError&, String& er
rorMessage); | 74 PassRefPtrWillBeRawPtr<DatabaseSync> openDatabaseSync(ExecutionContext*, con
st String& name, const String& expectedVersion, const String& displayName, unsig
ned long estimatedSize, PassOwnPtr<DatabaseCallback>, DatabaseError&, String& er
rorMessage); |
79 | 75 |
80 String fullPathForDatabase(SecurityOrigin*, const String& name, bool createI
fDoesNotExist = true); | 76 String fullPathForDatabase(SecurityOrigin*, const String& name, bool createI
fDoesNotExist = true); |
81 | 77 |
82 void closeDatabasesImmediately(const String& originIdentifier, const String&
name); | 78 void closeDatabasesImmediately(const String& originIdentifier, const String&
name); |
83 | 79 |
84 void interruptAllDatabasesForContext(DatabaseContext*); | 80 void interruptAllDatabasesForContext(DatabaseContext*); |
85 | 81 |
86 private: | 82 private: |
87 DatabaseManager(); | 83 DatabaseManager(); |
88 ~DatabaseManager() { } | 84 ~DatabaseManager() { } |
89 | 85 |
| 86 // This gets a DatabaseContext for the specified ExecutionContext. |
| 87 // If one doesn't already exist, it will create a new one. |
| 88 DatabaseContext* databaseContextFor(ExecutionContext*); |
90 // This gets a DatabaseContext for the specified ExecutionContext if | 89 // This gets a DatabaseContext for the specified ExecutionContext if |
91 // it already exist previously. Otherwise, it returns 0. | 90 // it already exist previously. Otherwise, it returns 0. |
92 PassRefPtr<DatabaseContext> existingDatabaseContextFor(ExecutionContext*); | 91 DatabaseContext* existingDatabaseContextFor(ExecutionContext*); |
93 | 92 |
94 PassRefPtrWillBeRawPtr<DatabaseBackendBase> openDatabaseBackend(ExecutionCon
text*, | 93 PassRefPtrWillBeRawPtr<DatabaseBackendBase> openDatabaseBackend(ExecutionCon
text*, |
95 DatabaseType, const String& name, const String& expectedVersion, const S
tring& displayName, | 94 DatabaseType, const String& name, const String& expectedVersion, const S
tring& displayName, |
96 unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError
&, String& errorMessage); | 95 unsigned long estimatedSize, bool setVersionInNewDatabase, DatabaseError
&, String& errorMessage); |
97 | 96 |
98 static void logErrorMessage(ExecutionContext*, const String& message); | 97 static void logErrorMessage(ExecutionContext*, const String& message); |
99 | 98 |
100 AbstractDatabaseServer* m_server; | 99 AbstractDatabaseServer* m_server; |
101 | 100 |
102 // Access to the following fields require locking m_contextMapLock: | 101 // Access to the following fields require locking m_contextMapLock: |
103 typedef HashMap<ExecutionContext*, DatabaseContext*> ContextMap; | 102 typedef HashMap<ExecutionContext*, DatabaseContext*> ContextMap; |
104 ContextMap m_contextMap; | 103 ContextMap m_contextMap; |
105 #if !ASSERT_DISABLED | 104 #if !ASSERT_DISABLED |
106 int m_databaseContextRegisteredCount; | 105 int m_databaseContextRegisteredCount; |
107 int m_databaseContextInstanceCount; | 106 int m_databaseContextInstanceCount; |
108 #endif | 107 #endif |
109 Mutex m_contextMapLock; | 108 Mutex m_contextMapLock; |
110 }; | 109 }; |
111 | 110 |
112 } // namespace WebCore | 111 } // namespace WebCore |
113 | 112 |
114 #endif // DatabaseManager_h | 113 #endif // DatabaseManager_h |
OLD | NEW |