Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2013 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 * | 7 * |
| 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 24 matching lines...) Expand all Loading... | |
| 35 #include "wtf/HashMap.h" | 35 #include "wtf/HashMap.h" |
| 36 #include "wtf/HashSet.h" | 36 #include "wtf/HashSet.h" |
| 37 #include "wtf/ThreadingPrimitives.h" | 37 #include "wtf/ThreadingPrimitives.h" |
| 38 #include "wtf/text/StringHash.h" | 38 #include "wtf/text/StringHash.h" |
| 39 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class Database; | 43 class Database; |
| 44 class DatabaseContext; | 44 class DatabaseContext; |
| 45 class InspectorDatabaseAgent; | |
| 45 class SecurityOrigin; | 46 class SecurityOrigin; |
| 46 | 47 |
| 47 class MODULES_EXPORT DatabaseTracker { | 48 class MODULES_EXPORT DatabaseTracker { |
| 48 WTF_MAKE_NONCOPYABLE(DatabaseTracker); USING_FAST_MALLOC(DatabaseTracker); | 49 WTF_MAKE_NONCOPYABLE(DatabaseTracker); USING_FAST_MALLOC(DatabaseTracker); |
| 49 public: | 50 public: |
| 50 static DatabaseTracker& tracker(); | 51 static DatabaseTracker& tracker(); |
| 51 // This singleton will potentially be used from multiple worker threads and the page's context thread simultaneously. To keep this safe, it's | 52 // This singleton will potentially be used from multiple worker threads and the page's context thread simultaneously. To keep this safe, it's |
| 52 // currently using 4 locks. In order to avoid deadlock when taking multiple locks, you must take them in the correct order: | 53 // currently using 4 locks. In order to avoid deadlock when taking multiple locks, you must take them in the correct order: |
| 53 // m_databaseGuard before quotaManager if both locks are needed. | 54 // m_databaseGuard before quotaManager if both locks are needed. |
| 54 // m_openDatabaseMapGuard before quotaManager if both locks are needed. | 55 // m_openDatabaseMapGuard before quotaManager if both locks are needed. |
| 55 // m_databaseGuard and m_openDatabaseMapGuard currently don't overlap. | 56 // m_databaseGuard and m_openDatabaseMapGuard currently don't overlap. |
| 56 // notificationMutex() is currently independent of the other locks. | 57 // notificationMutex() is currently independent of the other locks. |
| 57 | 58 |
| 58 bool canEstablishDatabase(DatabaseContext*, const String& name, const String & displayName, unsigned long estimatedSize, DatabaseError&); | 59 bool canEstablishDatabase(DatabaseContext*, const String& name, const String & displayName, unsigned long estimatedSize, DatabaseError&); |
| 59 String fullPathForDatabase(SecurityOrigin*, const String& name, bool createI fDoesNotExist = true); | 60 String fullPathForDatabase(SecurityOrigin*, const String& name, bool createI fDoesNotExist = true); |
| 60 | 61 |
| 61 void addOpenDatabase(Database*); | 62 void addOpenDatabase(Database*); |
| 62 void removeOpenDatabase(Database*); | 63 void removeOpenDatabase(Database*); |
| 63 | 64 |
| 64 unsigned long long getMaxSizeForDatabase(const Database*); | 65 unsigned long long getMaxSizeForDatabase(const Database*); |
| 65 | 66 |
| 66 void closeDatabasesImmediately(SecurityOrigin*, const String& name); | 67 void closeDatabasesImmediately(SecurityOrigin*, const String& name); |
| 68 void registerAllDatabasesInInspector(InspectorDatabaseAgent*); | |
|
michaeln
2016/04/13 22:18:18
It'd be nice to not have a dependency on the inspe
dgozman
2016/04/13 22:26:04
I'd rather go for callback than Memeber<> collecti
| |
| 67 | 69 |
| 68 void prepareToOpenDatabase(Database*); | 70 void prepareToOpenDatabase(Database*); |
| 69 void failedToOpenDatabase(Database*); | 71 void failedToOpenDatabase(Database*); |
| 70 | 72 |
| 71 private: | 73 private: |
| 72 using DatabaseSet = HashSet<UntracedMember<Database>>; | 74 using DatabaseSet = HashSet<UntracedMember<Database>>; |
| 73 using DatabaseNameMap = HashMap<String, DatabaseSet*>; | 75 using DatabaseNameMap = HashMap<String, DatabaseSet*>; |
| 74 using DatabaseOriginMap = HashMap<String, DatabaseNameMap*>; | 76 using DatabaseOriginMap = HashMap<String, DatabaseNameMap*>; |
| 75 class CloseOneDatabaseImmediatelyTask; | 77 class CloseOneDatabaseImmediatelyTask; |
| 76 | 78 |
| 77 DatabaseTracker(); | 79 DatabaseTracker(); |
| 78 | 80 |
| 79 void closeOneDatabaseImmediately(const String& originIdentifier, const Strin g& name, Database*); | 81 void closeOneDatabaseImmediately(const String& originIdentifier, const Strin g& name, Database*); |
| 80 | 82 |
| 81 Mutex m_openDatabaseMapGuard; | 83 Mutex m_openDatabaseMapGuard; |
| 82 | 84 |
| 83 // This map contains untraced pointers to a garbage-collected class. We can' t | 85 // This map contains untraced pointers to a garbage-collected class. We can' t |
| 84 // make this traceable because it is updated by multiple database threads. | 86 // make this traceable because it is updated by multiple database threads. |
| 85 // See http://crbug.com/417990 | 87 // See http://crbug.com/417990 |
| 86 mutable OwnPtr<DatabaseOriginMap> m_openDatabaseMap; | 88 mutable OwnPtr<DatabaseOriginMap> m_openDatabaseMap; |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 } // namespace blink | 91 } // namespace blink |
| 90 | 92 |
| 91 #endif // DatabaseTracker_h | 93 #endif // DatabaseTracker_h |
| OLD | NEW |