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

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

Issue 2740003: Implement IDBDatabase::createObjectStore. Also refactor IndexedDBCallbacks. (Closed)
Patch Set: Make sure indexed_db_context.cc is in the gypi file. Created 10 years, 6 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 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_
6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/id_map.h" 9 #include "base/id_map.h"
10 #include "base/process.h" 10 #include "base/process.h"
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
12 #include "chrome/browser/in_process_webkit/webkit_context.h" 12 #include "chrome/browser/in_process_webkit/webkit_context.h"
13 #include "ipc/ipc_message.h" 13 #include "ipc/ipc_message.h"
14 14
15 struct ViewHostMsg_IndexedDatabaseOpen_Params; 15 struct ViewHostMsg_IndexedDatabaseOpen_Params;
16 struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params;
16 17
17 namespace WebKit { 18 namespace WebKit {
18 class WebIDBDatabase; 19 class WebIDBDatabase;
19 class WebIDBIndex; 20 class WebIDBIndex;
21 class WebIDBObjectStore;
20 } 22 }
21 23
22 // Handles all IndexedDB related messages from a particular renderer process. 24 // Handles all IndexedDB related messages from a particular renderer process.
23 class IndexedDBDispatcherHost 25 class IndexedDBDispatcherHost
24 : public base::RefCountedThreadSafe<IndexedDBDispatcherHost> { 26 : public base::RefCountedThreadSafe<IndexedDBDispatcherHost> {
25 public: 27 public:
26 // Only call the constructor from the UI thread. 28 // Only call the constructor from the UI thread.
27 IndexedDBDispatcherHost(IPC::Message::Sender* sender, 29 IndexedDBDispatcherHost(IPC::Message::Sender* sender,
28 WebKitContext* webkit_context); 30 WebKitContext* webkit_context);
29 31
(...skipping 11 matching lines...) Expand all
41 // IO thread. May be called from any thread. 43 // IO thread. May be called from any thread.
42 void Send(IPC::Message* message); 44 void Send(IPC::Message* message);
43 45
44 // A shortcut for accessing our context. 46 // A shortcut for accessing our context.
45 IndexedDBContext* Context() { 47 IndexedDBContext* Context() {
46 return webkit_context_->indexed_db_context(); 48 return webkit_context_->indexed_db_context();
47 } 49 }
48 50
49 // The various IndexedDBCallbacks children call these methods to add the 51 // The various IndexedDBCallbacks children call these methods to add the
50 // results into the applicable map. See below for more details. 52 // results into the applicable map. See below for more details.
51 int32 AddIDBDatabase(WebKit::WebIDBDatabase* idb_database); 53 int32 Add(WebKit::WebIDBDatabase* idb_database);
52 // TODO(andreip/jorlow): Add functions for other maps here. 54 int32 Add(WebKit::WebIDBObjectStore* idb_object_store);
53 55
54 private: 56 private:
55 friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>; 57 friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>;
56 ~IndexedDBDispatcherHost(); 58 ~IndexedDBDispatcherHost();
57 59
58 // Message processing. Most of the work is delegated to the dispatcher hosts 60 // Message processing. Most of the work is delegated to the dispatcher hosts
59 // below. 61 // below.
60 void OnMessageReceivedWebKit(const IPC::Message& message); 62 void OnMessageReceivedWebKit(const IPC::Message& message);
61 void OnIndexedDatabaseOpen(const ViewHostMsg_IndexedDatabaseOpen_Params& p); 63 void OnIndexedDatabaseOpen(const ViewHostMsg_IndexedDatabaseOpen_Params& p);
62 64
63 // Helper templates. 65 // Helper templates.
64 template <class ReturnType> 66 template <class ReturnType>
65 ReturnType* GetOrTerminateProcess( 67 ReturnType* GetOrTerminateProcess(
66 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id, 68 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id,
67 IPC::Message* reply_msg, uint32 message_type); 69 IPC::Message* reply_msg, uint32 message_type);
68 70
69 template <typename ReplyType, typename MessageType, 71 template <typename ReplyType, typename MessageType,
70 typename WebObjectType, typename Method> 72 typename WebObjectType, typename Method>
71 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id, 73 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id,
72 IPC::Message* reply_msg, Method method); 74 IPC::Message* reply_msg, Method method);
73 75
74 template <typename ObjectType> 76 template <typename ObjectType>
75 void DestroyObject(IDMap<ObjectType, IDMapOwnPointer>* map, int32 object_id, 77 void DestroyObject(IDMap<ObjectType, IDMapOwnPointer>* map, int32 object_id,
76 uint32 message_type); 78 uint32 message_type);
77 79
78 class DatabaseDispatcherHost { 80 class DatabaseDispatcherHost {
79 public: 81 public:
80 DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); 82 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent);
81 ~DatabaseDispatcherHost(); 83 ~DatabaseDispatcherHost();
82 84
83 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); 85 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
84 void Send(IPC::Message* message); 86 void Send(IPC::Message* message);
85 87
86 void OnName(int32 idb_database_id, IPC::Message* reply_msg); 88 void OnName(int32 idb_database_id, IPC::Message* reply_msg);
87 void OnDescription(int32 idb_database_id, IPC::Message* reply_msg); 89 void OnDescription(int32 idb_database_id, IPC::Message* reply_msg);
88 void OnVersion(int32 idb_database_id, IPC::Message* reply_msg); 90 void OnVersion(int32 idb_database_id, IPC::Message* reply_msg);
89 void OnObjectStores(int32 idb_database_id, IPC::Message* reply_msg); 91 void OnObjectStores(int32 idb_database_id, IPC::Message* reply_msg);
92 void OnCreateObjectStore(
93 const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params);
94
90 void OnDestroyed(int32 idb_database_id); 95 void OnDestroyed(int32 idb_database_id);
91 96
92 IndexedDBDispatcherHost* parent_; 97 IndexedDBDispatcherHost* parent_;
93 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_; 98 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_;
94 }; 99 };
95 100
96 class IndexDispatcherHost { 101 class IndexDispatcherHost {
97 public: 102 public:
98 IndexDispatcherHost(IndexedDBDispatcherHost* parent); 103 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent);
99 ~IndexDispatcherHost(); 104 ~IndexDispatcherHost();
100 105
101 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); 106 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
102 void Send(IPC::Message* message); 107 void Send(IPC::Message* message);
103 108
104 void OnName(int32 idb_index_id, IPC::Message* reply_msg); 109 void OnName(int32 idb_index_id, IPC::Message* reply_msg);
105 void OnKeyPath(int32 idb_index_id, IPC::Message* reply_msg); 110 void OnKeyPath(int32 idb_index_id, IPC::Message* reply_msg);
106 void OnUnique(int32 idb_index_id, IPC::Message* reply_msg); 111 void OnUnique(int32 idb_index_id, IPC::Message* reply_msg);
107 void OnDestroyed(int32 idb_index_id); 112 void OnDestroyed(int32 idb_index_id);
108 113
109 IndexedDBDispatcherHost* parent_; 114 IndexedDBDispatcherHost* parent_;
110 IDMap<WebKit::WebIDBIndex, IDMapOwnPointer> map_; 115 IDMap<WebKit::WebIDBIndex, IDMapOwnPointer> map_;
111 }; 116 };
112 117
118 class ObjectStoreDispatcherHost {
119 public:
120 explicit ObjectStoreDispatcherHost(IndexedDBDispatcherHost* parent);
121 ~ObjectStoreDispatcherHost();
122
123 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
124 void Send(IPC::Message* message);
125
126 void OnName(int32 idb_object_store_id, IPC::Message* reply_msg);
127 void OnKeyPath(int32 idb_object_store_id, IPC::Message* reply_msg);
128 void OnDestroyed(int32 idb_object_store_id);
129
130 IndexedDBDispatcherHost* parent_;
131 IDMap<WebKit::WebIDBObjectStore, IDMapOwnPointer> map_;
132 };
113 // Only use on the IO thread. 133 // Only use on the IO thread.
114 IPC::Message::Sender* sender_; 134 IPC::Message::Sender* sender_;
115 135
116 // Data shared between renderer processes with the same profile. 136 // Data shared between renderer processes with the same profile.
117 scoped_refptr<WebKitContext> webkit_context_; 137 scoped_refptr<WebKitContext> webkit_context_;
118 138
119 // Only access on WebKit thread. 139 // Only access on WebKit thread.
120 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; 140 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_;
121 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; 141 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_;
142 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_;
122 143
123 // If we get a corrupt message from a renderer, we need to kill it using this 144 // If we get a corrupt message from a renderer, we need to kill it using this
124 // handle. 145 // handle.
125 base::ProcessHandle process_handle_; 146 base::ProcessHandle process_handle_;
126 147
127 // Used to dispatch messages to the correct view host. 148 // Used to dispatch messages to the correct view host.
128 int process_id_; 149 int process_id_;
129 150
130 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 151 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
131 }; 152 };
132 153
133 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ 154 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698