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

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: Restore CONTENT_EXPORT to Transaction 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 void HoldBlobDataHandle( 97 void HoldBlobDataHandle(
98 const std::string& uuid, 98 const std::string& uuid,
99 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle); 99 scoped_ptr<webkit_blob::BlobDataHandle> blob_data_handle);
100 void DropBlobDataHandle(const std::string& uuid); 100 void DropBlobDataHandle(const std::string& uuid);
101 101
102 private: 102 private:
103 // Friends to enable OnDestruct() delegation. 103 // Friends to enable OnDestruct() delegation.
104 friend class BrowserThread; 104 friend class BrowserThread;
105 friend class base::DeleteHelper<IndexedDBDispatcherHost>; 105 friend class base::DeleteHelper<IndexedDBDispatcherHost>;
106 106
107 virtual ~IndexedDBDispatcherHost(); 107 // Used in nested classes.
108 typedef std::map<int32, GURL> WebIDBObjectIDToURLMap;
108 109
109 // Message processing. Most of the work is delegated to the dispatcher hosts 110 typedef std::map<int64, GURL> TransactionIDToURLMap;
cmumford 2014/08/20 19:43:05 alphabetical?
jsbell 2014/08/22 20:50:01 Hrm... well, I went ahead and sorted these lines b
110 // below. 111 typedef std::map<int64, uint64> TransactionIDToSizeMap;
111 void OnIDBFactoryGetDatabaseNames( 112 typedef std::map<int64, int64> TransactionIDToDatabaseIDMap;
112 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p); 113 typedef std::map<std::string, webkit_blob::BlobDataHandle*> BlobDataHandleMap;
113 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p);
114
115 void OnIDBFactoryDeleteDatabase(
116 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p);
117
118 void OnAckReceivedBlobs(const std::vector<std::string>& uuids);
119 void OnPutHelper(const IndexedDBHostMsg_DatabasePut_Params& params,
120 std::vector<webkit_blob::BlobDataHandle*> handles);
121
122 void ResetDispatcherHosts();
123 114
124 // IDMap for RefCounted types 115 // IDMap for RefCounted types
125 template <typename RefCountedType> 116 template <typename RefCountedType>
126 class RefIDMap { 117 class RefIDMap {
127 private: 118 public:
128 typedef int32 KeyType; 119 typedef int32 KeyType;
129 120
130 public:
131 RefIDMap() {} 121 RefIDMap() {}
132 ~RefIDMap() {} 122 ~RefIDMap() {}
133 123
134 KeyType Add(RefCountedType* data) { 124 KeyType Add(RefCountedType* data) {
135 return map_.Add(new scoped_refptr<RefCountedType>(data)); 125 return map_.Add(new scoped_refptr<RefCountedType>(data));
136 } 126 }
137 127
138 RefCountedType* Lookup(KeyType id) { 128 RefCountedType* Lookup(KeyType id) {
139 scoped_refptr<RefCountedType>* ptr = map_.Lookup(id); 129 scoped_refptr<RefCountedType>* ptr = map_.Lookup(id);
140 if (ptr == NULL) 130 if (ptr == NULL)
141 return NULL; 131 return NULL;
142 return ptr->get(); 132 return ptr->get();
143 } 133 }
144 134
145 void Remove(KeyType id) { map_.Remove(id); } 135 void Remove(KeyType id) { map_.Remove(id); }
146 136
147 void set_check_on_null_data(bool value) { 137 void set_check_on_null_data(bool value) {
148 map_.set_check_on_null_data(value); 138 map_.set_check_on_null_data(value);
149 } 139 }
150 140
151 private: 141 private:
152 IDMap<scoped_refptr<RefCountedType>, IDMapOwnPointer> map_; 142 IDMap<scoped_refptr<RefCountedType>, IDMapOwnPointer> map_;
153 143
154 DISALLOW_COPY_AND_ASSIGN(RefIDMap); 144 DISALLOW_COPY_AND_ASSIGN(RefIDMap);
155 }; 145 };
156 146
157 // Helper templates.
158 template <class ReturnType>
159 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
160 int32 ipc_return_object_id);
161 template <class ReturnType>
162 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
163 int32 ipc_return_object_id);
164
165 template <typename MapType>
166 void DestroyObject(MapType* map, int32 ipc_object_id);
167
168 // Used in nested classes.
169 typedef std::map<int32, GURL> WebIDBObjectIDToURLMap;
170
171 typedef std::map<int64, GURL> TransactionIDToURLMap;
172 typedef std::map<int64, uint64> TransactionIDToSizeMap;
173 typedef std::map<int64, int64> TransactionIDToDatabaseIDMap;
174
175 class DatabaseDispatcherHost { 147 class DatabaseDispatcherHost {
176 public: 148 public:
177 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); 149 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent);
178 ~DatabaseDispatcherHost(); 150 ~DatabaseDispatcherHost();
179 151
180 void CloseAll(); 152 void CloseAll();
181 bool OnMessageReceived(const IPC::Message& message); 153 bool OnMessageReceived(const IPC::Message& message);
182 154
183 void OnCreateObjectStore( 155 void OnCreateObjectStore(
184 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params); 156 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 int unused_prefetches); 229 int unused_prefetches);
258 void OnDestroyed(int32 ipc_cursor_id); 230 void OnDestroyed(int32 ipc_cursor_id);
259 231
260 IndexedDBDispatcherHost* parent_; 232 IndexedDBDispatcherHost* parent_;
261 RefIDMap<IndexedDBCursor> map_; 233 RefIDMap<IndexedDBCursor> map_;
262 234
263 private: 235 private:
264 DISALLOW_COPY_AND_ASSIGN(CursorDispatcherHost); 236 DISALLOW_COPY_AND_ASSIGN(CursorDispatcherHost);
265 }; 237 };
266 238
239 virtual ~IndexedDBDispatcherHost();
240
241 // Helper templates.
242 template <class ReturnType>
243 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
244 int32 ipc_return_object_id);
245 template <class ReturnType>
246 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
247 int32 ipc_return_object_id);
248
249 template <typename MapType>
250 void DestroyObject(MapType* map, int32 ipc_object_id);
251
252 // Message processing. Most of the work is delegated to the dispatcher hosts
253 // below.
254 void OnIDBFactoryGetDatabaseNames(
255 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p);
256 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p);
257
258 void OnIDBFactoryDeleteDatabase(
259 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p);
260
261 void OnAckReceivedBlobs(const std::vector<std::string>& uuids);
262 void OnPutHelper(const IndexedDBHostMsg_DatabasePut_Params& params,
263 std::vector<webkit_blob::BlobDataHandle*> handles);
264
265 void ResetDispatcherHosts();
266
267 // The getter holds the context until OnChannelConnected() can be called from 267 // The getter holds the context until OnChannelConnected() can be called from
268 // the IO thread, which will extract the net::URLRequestContext from it. 268 // the IO thread, which will extract the net::URLRequestContext from it.
269 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 269 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
270 net::URLRequestContext* request_context_; 270 net::URLRequestContext* request_context_;
271 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 271 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
272 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; 272 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
273
274 typedef std::map<std::string, webkit_blob::BlobDataHandle*> BlobDataHandleMap;
275 BlobDataHandleMap blob_data_handle_map_; 273 BlobDataHandleMap blob_data_handle_map_;
276 274
277 // Only access on IndexedDB thread. 275 // Only access on IndexedDB thread.
278 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; 276 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_;
279 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; 277 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_;
280 278
281 // Used to set file permissions for blob storage. 279 // Used to set file permissions for blob storage.
282 int ipc_process_id_; 280 int ipc_process_id_;
283 281
284 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 282 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
285 }; 283 };
286 284
287 } // namespace content 285 } // namespace content
288 286
289 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 287 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698