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

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

Issue 475063004: IndexedDB + Coding Style: re-order enums/typedefs/... to match guide (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased after r291485 Created 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 void HoldBlobDataHandle(const std::string& uuid, 97 void HoldBlobDataHandle(const std::string& uuid,
98 scoped_ptr<storage::BlobDataHandle> blob_data_handle); 98 scoped_ptr<storage::BlobDataHandle> blob_data_handle);
99 void DropBlobDataHandle(const std::string& uuid); 99 void DropBlobDataHandle(const std::string& uuid);
100 100
101 private: 101 private:
102 // Friends to enable OnDestruct() delegation. 102 // Friends to enable OnDestruct() delegation.
103 friend class BrowserThread; 103 friend class BrowserThread;
104 friend class base::DeleteHelper<IndexedDBDispatcherHost>; 104 friend class base::DeleteHelper<IndexedDBDispatcherHost>;
105 105
106 virtual ~IndexedDBDispatcherHost(); 106 // Used in nested classes.
107 107 typedef std::map<std::string, storage::BlobDataHandle*> BlobDataHandleMap;
108 // Message processing. Most of the work is delegated to the dispatcher hosts 108 typedef std::map<int64, int64> TransactionIDToDatabaseIDMap;
109 // below. 109 typedef std::map<int64, uint64> TransactionIDToSizeMap;
110 void OnIDBFactoryGetDatabaseNames( 110 typedef std::map<int64, GURL> TransactionIDToURLMap;
111 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p); 111 typedef std::map<int32, GURL> WebIDBObjectIDToURLMap;
112 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p);
113
114 void OnIDBFactoryDeleteDatabase(
115 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p);
116
117 void OnAckReceivedBlobs(const std::vector<std::string>& uuids);
118 void OnPutHelper(const IndexedDBHostMsg_DatabasePut_Params& params,
119 std::vector<storage::BlobDataHandle*> handles);
120
121 void ResetDispatcherHosts();
122 112
123 // IDMap for RefCounted types 113 // IDMap for RefCounted types
124 template <typename RefCountedType> 114 template <typename RefCountedType>
125 class RefIDMap { 115 class RefIDMap {
126 private: 116 public:
127 typedef int32 KeyType; 117 typedef int32 KeyType;
128 118
129 public:
130 RefIDMap() {} 119 RefIDMap() {}
131 ~RefIDMap() {} 120 ~RefIDMap() {}
132 121
133 KeyType Add(RefCountedType* data) { 122 KeyType Add(RefCountedType* data) {
134 return map_.Add(new scoped_refptr<RefCountedType>(data)); 123 return map_.Add(new scoped_refptr<RefCountedType>(data));
135 } 124 }
136 125
137 RefCountedType* Lookup(KeyType id) { 126 RefCountedType* Lookup(KeyType id) {
138 scoped_refptr<RefCountedType>* ptr = map_.Lookup(id); 127 scoped_refptr<RefCountedType>* ptr = map_.Lookup(id);
139 if (ptr == NULL) 128 if (ptr == NULL)
140 return NULL; 129 return NULL;
141 return ptr->get(); 130 return ptr->get();
142 } 131 }
143 132
144 void Remove(KeyType id) { map_.Remove(id); } 133 void Remove(KeyType id) { map_.Remove(id); }
145 134
146 void set_check_on_null_data(bool value) { 135 void set_check_on_null_data(bool value) {
147 map_.set_check_on_null_data(value); 136 map_.set_check_on_null_data(value);
148 } 137 }
149 138
150 private: 139 private:
151 IDMap<scoped_refptr<RefCountedType>, IDMapOwnPointer> map_; 140 IDMap<scoped_refptr<RefCountedType>, IDMapOwnPointer> map_;
152 141
153 DISALLOW_COPY_AND_ASSIGN(RefIDMap); 142 DISALLOW_COPY_AND_ASSIGN(RefIDMap);
154 }; 143 };
155 144
156 // Helper templates.
157 template <class ReturnType>
158 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
159 int32 ipc_return_object_id);
160 template <class ReturnType>
161 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
162 int32 ipc_return_object_id);
163
164 template <typename MapType>
165 void DestroyObject(MapType* map, int32 ipc_object_id);
166
167 // Used in nested classes.
168 typedef std::map<int32, GURL> WebIDBObjectIDToURLMap;
169
170 typedef std::map<int64, GURL> TransactionIDToURLMap;
171 typedef std::map<int64, uint64> TransactionIDToSizeMap;
172 typedef std::map<int64, int64> TransactionIDToDatabaseIDMap;
173
174 class DatabaseDispatcherHost { 145 class DatabaseDispatcherHost {
175 public: 146 public:
176 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); 147 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent);
177 ~DatabaseDispatcherHost(); 148 ~DatabaseDispatcherHost();
178 149
179 void CloseAll(); 150 void CloseAll();
180 bool OnMessageReceived(const IPC::Message& message); 151 bool OnMessageReceived(const IPC::Message& message);
181 152
182 void OnCreateObjectStore( 153 void OnCreateObjectStore(
183 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params); 154 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 int unused_prefetches); 227 int unused_prefetches);
257 void OnDestroyed(int32 ipc_cursor_id); 228 void OnDestroyed(int32 ipc_cursor_id);
258 229
259 IndexedDBDispatcherHost* parent_; 230 IndexedDBDispatcherHost* parent_;
260 RefIDMap<IndexedDBCursor> map_; 231 RefIDMap<IndexedDBCursor> map_;
261 232
262 private: 233 private:
263 DISALLOW_COPY_AND_ASSIGN(CursorDispatcherHost); 234 DISALLOW_COPY_AND_ASSIGN(CursorDispatcherHost);
264 }; 235 };
265 236
237 virtual ~IndexedDBDispatcherHost();
238
239 // Helper templates.
240 template <class ReturnType>
241 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
242 int32 ipc_return_object_id);
243 template <class ReturnType>
244 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
245 int32 ipc_return_object_id);
246
247 template <typename MapType>
248 void DestroyObject(MapType* map, int32 ipc_object_id);
249
250 // Message processing. Most of the work is delegated to the dispatcher hosts
251 // below.
252 void OnIDBFactoryGetDatabaseNames(
253 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p);
254 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p);
255
256 void OnIDBFactoryDeleteDatabase(
257 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p);
258
259 void OnAckReceivedBlobs(const std::vector<std::string>& uuids);
260 void OnPutHelper(const IndexedDBHostMsg_DatabasePut_Params& params,
261 std::vector<storage::BlobDataHandle*> handles);
262
263 void ResetDispatcherHosts();
264
266 // The getter holds the context until OnChannelConnected() can be called from 265 // The getter holds the context until OnChannelConnected() can be called from
267 // the IO thread, which will extract the net::URLRequestContext from it. 266 // the IO thread, which will extract the net::URLRequestContext from it.
268 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 267 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
269 net::URLRequestContext* request_context_; 268 net::URLRequestContext* request_context_;
270 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 269 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
271 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; 270 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
272 271
273 typedef std::map<std::string, storage::BlobDataHandle*> BlobDataHandleMap;
274 BlobDataHandleMap blob_data_handle_map_; 272 BlobDataHandleMap blob_data_handle_map_;
275 273
276 // Only access on IndexedDB thread. 274 // Only access on IndexedDB thread.
277 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; 275 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_;
278 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; 276 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_;
279 277
280 // Used to set file permissions for blob storage. 278 // Used to set file permissions for blob storage.
281 int ipc_process_id_; 279 int ipc_process_id_;
282 280
283 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 281 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
284 }; 282 };
285 283
286 } // namespace content 284 } // namespace content
287 285
288 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 286 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_database.h ('k') | content/browser/indexed_db/indexed_db_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698