| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Google, Inc. All Rights Reserved. | 3 * Copyright (C) 2011 Google, Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 * | 25 * |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifndef DatabaseContext_h | 28 #ifndef DatabaseContext_h |
| 29 #define DatabaseContext_h | 29 #define DatabaseContext_h |
| 30 | 30 |
| 31 #include "core/dom/ActiveDOMObject.h" | 31 #include "core/dom/ActiveDOMObject.h" |
| 32 #include "core/workers/WorkerGlobalScope.h" |
| 32 #include "platform/heap/Handle.h" | 33 #include "platform/heap/Handle.h" |
| 33 #include "wtf/PassRefPtr.h" | 34 #include "wtf/PassRefPtr.h" |
| 34 #include "wtf/ThreadSafeRefCounted.h" | 35 #include "wtf/ThreadSafeRefCounted.h" |
| 35 | 36 |
| 36 namespace WebCore { | 37 namespace WebCore { |
| 37 | 38 |
| 38 class Database; | 39 class Database; |
| 39 class DatabaseBackendBase; | 40 class DatabaseBackendBase; |
| 40 class DatabaseContext; | 41 class DatabaseContext; |
| 41 class TaskSynchronizer; | 42 class TaskSynchronizer; |
| 42 class DatabaseThread; | 43 class DatabaseThread; |
| 43 class ExecutionContext; | 44 class ExecutionContext; |
| 44 class SecurityOrigin; | 45 class SecurityOrigin; |
| 45 | 46 |
| 46 class DatabaseContext FINAL : public ThreadSafeRefCountedWillBeGarbageCollectedF
inalized<DatabaseContext>, public ActiveDOMObject { | 47 class DatabaseContext FINAL |
| 48 : public ThreadSafeRefCountedWillBeGarbageCollectedFinalized<DatabaseContext
> |
| 49 , public ActiveDOMObject |
| 50 , private WorkerGlobalScope::TerminationObserver { |
| 47 public: | 51 public: |
| 48 friend class DatabaseManager; | 52 friend class DatabaseManager; |
| 49 | 53 |
| 50 static PassRefPtrWillBeRawPtr<DatabaseContext> create(ExecutionContext*); | 54 static PassRefPtrWillBeRawPtr<DatabaseContext> create(ExecutionContext*); |
| 51 | 55 |
| 52 virtual ~DatabaseContext(); | 56 virtual ~DatabaseContext(); |
| 53 void trace(Visitor*); | 57 void trace(Visitor*); |
| 54 | 58 |
| 55 // For life-cycle management (inherited from ActiveDOMObject): | 59 // For life-cycle management (inherited from ActiveDOMObject): |
| 56 virtual void contextDestroyed() OVERRIDE; | 60 virtual void contextDestroyed() OVERRIDE; |
| 57 virtual void willStop() OVERRIDE; | |
| 58 virtual void stop() OVERRIDE; | 61 virtual void stop() OVERRIDE; |
| 59 | 62 |
| 60 DatabaseContext* backend(); | 63 DatabaseContext* backend(); |
| 61 DatabaseThread* databaseThread(); | 64 DatabaseThread* databaseThread(); |
| 62 | 65 |
| 63 void setHasOpenDatabases() { m_hasOpenDatabases = true; } | 66 void setHasOpenDatabases() { m_hasOpenDatabases = true; } |
| 64 void didOpenDatabase(DatabaseBackendBase&); | 67 void didOpenDatabase(DatabaseBackendBase&); |
| 65 void didCloseDatabase(DatabaseBackendBase&); | 68 void didCloseDatabase(DatabaseBackendBase&); |
| 66 // Blocks the caller thread until cleanup tasks are completed. | 69 // Blocks the caller thread until cleanup tasks are completed. |
| 67 void stopDatabases(); | 70 void stopDatabases(); |
| 68 | 71 |
| 69 bool allowDatabaseAccess() const; | 72 bool allowDatabaseAccess() const; |
| 70 | 73 |
| 71 SecurityOrigin* securityOrigin() const; | 74 SecurityOrigin* securityOrigin() const; |
| 72 bool isContextThread() const; | 75 bool isContextThread() const; |
| 73 | 76 |
| 74 private: | 77 private: |
| 75 explicit DatabaseContext(ExecutionContext*); | 78 explicit DatabaseContext(ExecutionContext*); |
| 76 | 79 |
| 80 virtual void wasRequestedToTerminate() OVERRIDE; |
| 77 void stopSyncDatabases(); | 81 void stopSyncDatabases(); |
| 78 | 82 |
| 79 RefPtrWillBeMember<DatabaseThread> m_databaseThread; | 83 RefPtrWillBeMember<DatabaseThread> m_databaseThread; |
| 80 #if ENABLE(OILPAN) | 84 #if ENABLE(OILPAN) |
| 81 class DatabaseCloser { | 85 class DatabaseCloser { |
| 82 public: | 86 public: |
| 83 explicit DatabaseCloser(DatabaseBackendBase& database) : m_database(data
base) { } | 87 explicit DatabaseCloser(DatabaseBackendBase& database) : m_database(data
base) { } |
| 84 ~DatabaseCloser(); | 88 ~DatabaseCloser(); |
| 85 | 89 |
| 86 private: | 90 private: |
| 87 DatabaseBackendBase& m_database; | 91 DatabaseBackendBase& m_database; |
| 88 }; | 92 }; |
| 89 HeapHashMap<WeakMember<DatabaseBackendBase>, OwnPtr<DatabaseCloser> > m_open
SyncDatabases; | 93 HeapHashMap<WeakMember<DatabaseBackendBase>, OwnPtr<DatabaseCloser> > m_open
SyncDatabases; |
| 90 #else | 94 #else |
| 91 // The contents of m_openSyncDatabases are raw pointers. It's safe because | 95 // The contents of m_openSyncDatabases are raw pointers. It's safe because |
| 92 // DatabaseBackendSync is always closed before destruction. | 96 // DatabaseBackendSync is always closed before destruction. |
| 93 HashSet<DatabaseBackendBase*> m_openSyncDatabases; | 97 HashSet<DatabaseBackendBase*> m_openSyncDatabases; |
| 94 #endif | 98 #endif |
| 95 bool m_hasOpenDatabases; // This never changes back to false, even after the
database thread is closed. | 99 bool m_hasOpenDatabases; // This never changes back to false, even after the
database thread is closed. |
| 96 bool m_hasRequestedTermination; | 100 bool m_hasRequestedTermination; |
| 97 }; | 101 }; |
| 98 | 102 |
| 99 } // namespace WebCore | 103 } // namespace WebCore |
| 100 | 104 |
| 101 #endif // DatabaseContext_h | 105 #endif // DatabaseContext_h |
| OLD | NEW |