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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/DatabaseTracker.h

Issue 1880273002: [DevTools] Create last agents on attach, modify InspectorDatabaseAgent to support it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: two databases in the test Created 4 years, 8 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) 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 14 matching lines...) Expand all
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef DatabaseTracker_h 29 #ifndef DatabaseTracker_h
30 #define DatabaseTracker_h 30 #define DatabaseTracker_h
31 31
32 #include "modules/ModulesExport.h" 32 #include "modules/ModulesExport.h"
33 #include "modules/webdatabase/DatabaseError.h" 33 #include "modules/webdatabase/DatabaseError.h"
34 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
35 #include "wtf/Functional.h"
35 #include "wtf/HashMap.h" 36 #include "wtf/HashMap.h"
36 #include "wtf/HashSet.h" 37 #include "wtf/HashSet.h"
37 #include "wtf/ThreadingPrimitives.h" 38 #include "wtf/ThreadingPrimitives.h"
38 #include "wtf/text/StringHash.h" 39 #include "wtf/text/StringHash.h"
39 #include "wtf/text/WTFString.h" 40 #include "wtf/text/WTFString.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 class Database; 44 class Database;
44 class DatabaseContext; 45 class DatabaseContext;
46 class Page;
45 class SecurityOrigin; 47 class SecurityOrigin;
46 48
47 class MODULES_EXPORT DatabaseTracker { 49 class MODULES_EXPORT DatabaseTracker {
48 WTF_MAKE_NONCOPYABLE(DatabaseTracker); USING_FAST_MALLOC(DatabaseTracker); 50 WTF_MAKE_NONCOPYABLE(DatabaseTracker); USING_FAST_MALLOC(DatabaseTracker);
49 public: 51 public:
50 static DatabaseTracker& tracker(); 52 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 53 // 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: 54 // 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. 55 // m_databaseGuard before quotaManager if both locks are needed.
54 // m_openDatabaseMapGuard before quotaManager if both locks are needed. 56 // m_openDatabaseMapGuard before quotaManager if both locks are needed.
55 // m_databaseGuard and m_openDatabaseMapGuard currently don't overlap. 57 // m_databaseGuard and m_openDatabaseMapGuard currently don't overlap.
56 // notificationMutex() is currently independent of the other locks. 58 // notificationMutex() is currently independent of the other locks.
57 59
58 bool canEstablishDatabase(DatabaseContext*, const String& name, const String & displayName, unsigned long estimatedSize, DatabaseError&); 60 bool canEstablishDatabase(DatabaseContext*, const String& name, const String & displayName, unsigned long estimatedSize, DatabaseError&);
59 String fullPathForDatabase(SecurityOrigin*, const String& name, bool createI fDoesNotExist = true); 61 String fullPathForDatabase(SecurityOrigin*, const String& name, bool createI fDoesNotExist = true);
60 62
61 void addOpenDatabase(Database*); 63 void addOpenDatabase(Database*);
62 void removeOpenDatabase(Database*); 64 void removeOpenDatabase(Database*);
63 65
64 unsigned long long getMaxSizeForDatabase(const Database*); 66 unsigned long long getMaxSizeForDatabase(const Database*);
65 67
66 void closeDatabasesImmediately(SecurityOrigin*, const String& name); 68 void closeDatabasesImmediately(SecurityOrigin*, const String& name);
67 69
70 using DatabaseCallback = Function<void(Database*)>;
71 void forEachOpenDatabaseInPage(Page*, PassOwnPtr<DatabaseCallback>);
72
68 void prepareToOpenDatabase(Database*); 73 void prepareToOpenDatabase(Database*);
69 void failedToOpenDatabase(Database*); 74 void failedToOpenDatabase(Database*);
70 75
71 private: 76 private:
72 using DatabaseSet = HashSet<UntracedMember<Database>>; 77 using DatabaseSet = HashSet<UntracedMember<Database>>;
73 using DatabaseNameMap = HashMap<String, DatabaseSet*>; 78 using DatabaseNameMap = HashMap<String, DatabaseSet*>;
74 using DatabaseOriginMap = HashMap<String, DatabaseNameMap*>; 79 using DatabaseOriginMap = HashMap<String, DatabaseNameMap*>;
75 class CloseOneDatabaseImmediatelyTask; 80 class CloseOneDatabaseImmediatelyTask;
76 81
77 DatabaseTracker(); 82 DatabaseTracker();
78 83
79 void closeOneDatabaseImmediately(const String& originIdentifier, const Strin g& name, Database*); 84 void closeOneDatabaseImmediately(const String& originIdentifier, const Strin g& name, Database*);
80 85
81 Mutex m_openDatabaseMapGuard; 86 Mutex m_openDatabaseMapGuard;
82 87
83 // This map contains untraced pointers to a garbage-collected class. We can' t 88 // 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. 89 // make this traceable because it is updated by multiple database threads.
85 // See http://crbug.com/417990 90 // See http://crbug.com/417990
86 mutable OwnPtr<DatabaseOriginMap> m_openDatabaseMap; 91 mutable OwnPtr<DatabaseOriginMap> m_openDatabaseMap;
87 }; 92 };
88 93
89 } // namespace blink 94 } // namespace blink
90 95
91 #endif // DatabaseTracker_h 96 #endif // DatabaseTracker_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698