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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_dispatcher_host.h

Issue 7470008: Improve IndexedDB's quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: improve names and comments, better map cleanup Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/id_map.h" 10 #include "base/id_map.h"
(...skipping 27 matching lines...) Expand all
38 // Only call the constructor from the UI thread. 38 // Only call the constructor from the UI thread.
39 IndexedDBDispatcherHost(int process_id, WebKitContext* webkit_context); 39 IndexedDBDispatcherHost(int process_id, WebKitContext* webkit_context);
40 40
41 // BrowserMessageFilter implementation. 41 // BrowserMessageFilter implementation.
42 virtual void OnChannelClosing(); 42 virtual void OnChannelClosing();
43 virtual void OverrideThreadForMessage(const IPC::Message& message, 43 virtual void OverrideThreadForMessage(const IPC::Message& message,
44 BrowserThread::ID* thread); 44 BrowserThread::ID* thread);
45 virtual bool OnMessageReceived(const IPC::Message& message, 45 virtual bool OnMessageReceived(const IPC::Message& message,
46 bool* message_was_ok); 46 bool* message_was_ok);
47 47
48 void TransactionComplete(int32 transaction_id);
49 void TransactionAborted(int32 transaction_id);
50
48 // A shortcut for accessing our context. 51 // A shortcut for accessing our context.
49 IndexedDBContext* Context() { 52 IndexedDBContext* Context() {
50 return webkit_context_->indexed_db_context(); 53 return webkit_context_->indexed_db_context();
51 } 54 }
52 55
53 // The various IndexedDBCallbacks children call these methods to add the 56 // The various IndexedDBCallbacks children call these methods to add the
54 // results into the applicable map. See below for more details. 57 // results into the applicable map. See below for more details.
55 int32 Add(WebKit::WebIDBCursor* idb_cursor); 58 int32 Add(WebKit::WebIDBCursor* idb_cursor);
56 int32 Add(WebKit::WebIDBDatabase* idb_database, const GURL& origin_url); 59 int32 Add(WebKit::WebIDBDatabase* idb_database, const GURL& origin_url);
57 int32 Add(WebKit::WebIDBIndex* idb_index); 60 int32 Add(WebKit::WebIDBIndex* idb_index);
58 int32 Add(WebKit::WebIDBObjectStore* idb_object_store); 61 int32 Add(WebKit::WebIDBObjectStore* idb_object_store);
59 int32 Add(WebKit::WebIDBTransaction* idb_transaction); 62 int32 Add(WebKit::WebIDBTransaction* idb_transaction, const GURL& origin_url);
60 63
61 private: 64 private:
62 virtual ~IndexedDBDispatcherHost(); 65 virtual ~IndexedDBDispatcherHost();
63 66
64 // Message processing. Most of the work is delegated to the dispatcher hosts 67 // Message processing. Most of the work is delegated to the dispatcher hosts
65 // below. 68 // below.
66 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p); 69 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p);
67 70
68 void OnIDBFactoryDeleteDatabase( 71 void OnIDBFactoryDeleteDatabase(
69 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p); 72 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p);
70 73
71 void ResetDispatcherHosts(); 74 void ResetDispatcherHosts();
75 void CleanupTransactionMaps(int32 transaction_id);
72 76
73 // Helper templates. 77 // Helper templates.
74 template <class ReturnType> 78 template <class ReturnType>
75 ReturnType* GetOrTerminateProcess( 79 ReturnType* GetOrTerminateProcess(
76 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id); 80 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id);
77 81
78 template <typename ReplyType, typename WebObjectType, typename Method> 82 template <typename ReplyType, typename WebObjectType, typename Method>
79 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id, 83 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id,
80 ReplyType* reply, Method method); 84 ReplyType* reply, Method method);
81 85
82 template <typename ObjectType> 86 template <typename ObjectType>
83 void DestroyObject(IDMap<ObjectType, IDMapOwnPointer>* map, int32 object_id); 87 void DestroyObject(IDMap<ObjectType, IDMapOwnPointer>* map, int32 object_id);
84 88
89 // Used in nested classes.
90 typedef std::map<int32, GURL> WebIDBObjectIDToURLMap;
91 typedef std::map<int32, int64> WebIDBTransactionIDToSizeMap;
92
85 class DatabaseDispatcherHost { 93 class DatabaseDispatcherHost {
86 public: 94 public:
87 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); 95 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent);
88 ~DatabaseDispatcherHost(); 96 ~DatabaseDispatcherHost();
89 97
90 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); 98 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
91 void Send(IPC::Message* message); 99 void Send(IPC::Message* message);
92 100
93 void OnName(int32 idb_database_id, string16* name); 101 void OnName(int32 idb_database_id, string16* name);
94 void OnVersion(int32 idb_database_id, string16* version); 102 void OnVersion(int32 idb_database_id, string16* version);
(...skipping 14 matching lines...) Expand all
109 const std::vector<string16>& names, 117 const std::vector<string16>& names,
110 int32 mode, int32 timeout, 118 int32 mode, int32 timeout,
111 int32* idb_transaction_id, 119 int32* idb_transaction_id,
112 WebKit::WebExceptionCode* ec); 120 WebKit::WebExceptionCode* ec);
113 void OnOpen(int32 idb_database_id, int32 response_id); 121 void OnOpen(int32 idb_database_id, int32 response_id);
114 void OnClose(int32 idb_database_id); 122 void OnClose(int32 idb_database_id);
115 void OnDestroyed(int32 idb_database_id); 123 void OnDestroyed(int32 idb_database_id);
116 124
117 IndexedDBDispatcherHost* parent_; 125 IndexedDBDispatcherHost* parent_;
118 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_; 126 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_;
119 typedef std::map<int32, GURL> WebIDBDatabaseIDToURLMap; 127 WebIDBObjectIDToURLMap database_url_map_;
120 WebIDBDatabaseIDToURLMap url_map_;
121 }; 128 };
122 129
123 class IndexDispatcherHost { 130 class IndexDispatcherHost {
124 public: 131 public:
125 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent); 132 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent);
126 ~IndexDispatcherHost(); 133 ~IndexDispatcherHost();
127 134
128 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); 135 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
129 void Send(IPC::Message* message); 136 void Send(IPC::Message* message);
130 137
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 void OnObjectStore(int32 transaction_id, 254 void OnObjectStore(int32 transaction_id,
248 const string16& name, 255 const string16& name,
249 int32* object_store_id, 256 int32* object_store_id,
250 WebKit::WebExceptionCode* ec); 257 WebKit::WebExceptionCode* ec);
251 void OnDidCompleteTaskEvents(int transaction_id); 258 void OnDidCompleteTaskEvents(int transaction_id);
252 void OnDestroyed(int32 idb_transaction_id); 259 void OnDestroyed(int32 idb_transaction_id);
253 260
254 IndexedDBDispatcherHost* parent_; 261 IndexedDBDispatcherHost* parent_;
255 typedef IDMap<WebKit::WebIDBTransaction, IDMapOwnPointer> MapType; 262 typedef IDMap<WebKit::WebIDBTransaction, IDMapOwnPointer> MapType;
256 MapType map_; 263 MapType map_;
264 WebIDBObjectIDToURLMap transaction_url_map_;
265 WebIDBTransactionIDToSizeMap transaction_size_map_;
257 }; 266 };
258 267
259 // Data shared between renderer processes with the same profile. 268 // Data shared between renderer processes with the same profile.
260 scoped_refptr<WebKitContext> webkit_context_; 269 scoped_refptr<WebKitContext> webkit_context_;
261 270
262 // Only access on WebKit thread. 271 // Only access on WebKit thread.
263 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; 272 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_;
264 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; 273 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_;
265 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_; 274 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_;
266 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; 275 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_;
267 scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_; 276 scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_;
268 277
269 // Used to dispatch messages to the correct view host. 278 // Used to dispatch messages to the correct view host.
270 int process_id_; 279 int process_id_;
271 280
272 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 281 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
273 }; 282 };
274 283
275 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ 284 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698