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

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

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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) 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 <stdint.h>
9
8 #include <map> 10 #include <map>
9 #include <string> 11 #include <string>
10 #include <utility> 12 #include <utility>
11 #include <vector> 13 #include <vector>
12 14
13 #include "base/basictypes.h"
14 #include "base/id_map.h" 15 #include "base/id_map.h"
16 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
16 #include "content/browser/fileapi/chrome_blob_storage_context.h" 18 #include "content/browser/fileapi/chrome_blob_storage_context.h"
17 #include "content/public/browser/browser_message_filter.h" 19 #include "content/public/browser/browser_message_filter.h"
18 #include "net/url_request/url_request_context_getter.h" 20 #include "net/url_request/url_request_context_getter.h"
19 #include "storage/browser/blob/blob_data_handle.h" 21 #include "storage/browser/blob/blob_data_handle.h"
20 #include "url/gurl.h" 22 #include "url/gurl.h"
21 23
22 struct IndexedDBDatabaseMetadata; 24 struct IndexedDBDatabaseMetadata;
23 struct IndexedDBHostMsg_DatabaseCount_Params; 25 struct IndexedDBHostMsg_DatabaseCount_Params;
24 struct IndexedDBHostMsg_DatabaseCreateIndex_Params; 26 struct IndexedDBHostMsg_DatabaseCreateIndex_Params;
(...skipping 29 matching lines...) Expand all
54 ChromeBlobStorageContext* blob_storage_context); 56 ChromeBlobStorageContext* blob_storage_context);
55 IndexedDBDispatcherHost(int ipc_process_id, 57 IndexedDBDispatcherHost(int ipc_process_id,
56 net::URLRequestContext* request_context, 58 net::URLRequestContext* request_context,
57 IndexedDBContextImpl* indexed_db_context, 59 IndexedDBContextImpl* indexed_db_context,
58 ChromeBlobStorageContext* blob_storage_context); 60 ChromeBlobStorageContext* blob_storage_context);
59 61
60 static ::IndexedDBDatabaseMetadata ConvertMetadata( 62 static ::IndexedDBDatabaseMetadata ConvertMetadata(
61 const content::IndexedDBDatabaseMetadata& metadata); 63 const content::IndexedDBDatabaseMetadata& metadata);
62 64
63 // BrowserMessageFilter implementation. 65 // BrowserMessageFilter implementation.
64 void OnChannelConnected(int32 peer_pid) override; 66 void OnChannelConnected(int32_t peer_pid) override;
65 void OnChannelClosing() override; 67 void OnChannelClosing() override;
66 void OnDestruct() const override; 68 void OnDestruct() const override;
67 base::TaskRunner* OverrideTaskRunnerForMessage( 69 base::TaskRunner* OverrideTaskRunnerForMessage(
68 const IPC::Message& message) override; 70 const IPC::Message& message) override;
69 bool OnMessageReceived(const IPC::Message& message) override; 71 bool OnMessageReceived(const IPC::Message& message) override;
70 72
71 void FinishTransaction(int64 host_transaction_id, bool committed); 73 void FinishTransaction(int64_t host_transaction_id, bool committed);
72 74
73 // A shortcut for accessing our context. 75 // A shortcut for accessing our context.
74 IndexedDBContextImpl* Context() { return indexed_db_context_.get(); } 76 IndexedDBContextImpl* Context() { return indexed_db_context_.get(); }
75 storage::BlobStorageContext* blob_storage_context() const { 77 storage::BlobStorageContext* blob_storage_context() const {
76 return blob_storage_context_->context(); 78 return blob_storage_context_->context();
77 } 79 }
78 80
79 // IndexedDBCallbacks call these methods to add the results into the 81 // IndexedDBCallbacks call these methods to add the results into the
80 // applicable map. See below for more details. 82 // applicable map. See below for more details.
81 int32 Add(IndexedDBCursor* cursor); 83 int32_t Add(IndexedDBCursor* cursor);
82 int32 Add(IndexedDBConnection* connection, 84 int32_t Add(IndexedDBConnection* connection,
83 int32 ipc_thread_id, 85 int32_t ipc_thread_id,
84 const GURL& origin_url); 86 const GURL& origin_url);
85 87
86 void RegisterTransactionId(int64 host_transaction_id, const GURL& origin_url); 88 void RegisterTransactionId(int64_t host_transaction_id,
89 const GURL& origin_url);
87 90
88 IndexedDBCursor* GetCursorFromId(int32 ipc_cursor_id); 91 IndexedDBCursor* GetCursorFromId(int32_t ipc_cursor_id);
89 92
90 // These are called to map a 32-bit front-end (renderer-specific) transaction 93 // These are called to map a 32-bit front-end (renderer-specific) transaction
91 // id to and from a back-end ("host") transaction id that encodes the process 94 // id to and from a back-end ("host") transaction id that encodes the process
92 // id in the high 32 bits. The mapping is host-specific and ids are validated. 95 // id in the high 32 bits. The mapping is host-specific and ids are validated.
93 int64 HostTransactionId(int64 transaction_id); 96 int64_t HostTransactionId(int64_t transaction_id);
94 int64 RendererTransactionId(int64 host_transaction_id); 97 int64_t RendererTransactionId(int64_t host_transaction_id);
95 98
96 // These are called to decode a host transaction ID, for diagnostic purposes. 99 // These are called to decode a host transaction ID, for diagnostic purposes.
97 static uint32 TransactionIdToRendererTransactionId(int64 host_transaction_id); 100 static uint32_t TransactionIdToRendererTransactionId(
98 static uint32 TransactionIdToProcessId(int64 host_transaction_id); 101 int64_t host_transaction_id);
102 static uint32_t TransactionIdToProcessId(int64_t host_transaction_id);
99 103
100 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info); 104 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info);
101 105
102 private: 106 private:
103 // Friends to enable OnDestruct() delegation. 107 // Friends to enable OnDestruct() delegation.
104 friend class BrowserThread; 108 friend class BrowserThread;
105 friend class base::DeleteHelper<IndexedDBDispatcherHost>; 109 friend class base::DeleteHelper<IndexedDBDispatcherHost>;
106 110
107 // Used in nested classes. 111 // Used in nested classes.
108 typedef std::map<std::string, std::pair<storage::BlobDataHandle*, int>> 112 typedef std::map<std::string, std::pair<storage::BlobDataHandle*, int>>
109 BlobDataHandleMap; 113 BlobDataHandleMap;
110 typedef std::map<int64, int64> TransactionIDToDatabaseIDMap; 114 typedef std::map<int64_t, int64_t> TransactionIDToDatabaseIDMap;
111 typedef std::map<int64, uint64> TransactionIDToSizeMap; 115 typedef std::map<int64_t, uint64_t> TransactionIDToSizeMap;
112 typedef std::map<int64, GURL> TransactionIDToURLMap; 116 typedef std::map<int64_t, GURL> TransactionIDToURLMap;
113 typedef std::map<int32, GURL> WebIDBObjectIDToURLMap; 117 typedef std::map<int32_t, GURL> WebIDBObjectIDToURLMap;
114 118
115 // IDMap for RefCounted types 119 // IDMap for RefCounted types
116 template <typename RefCountedType> 120 template <typename RefCountedType>
117 class RefIDMap { 121 class RefIDMap {
118 public: 122 public:
119 typedef int32 KeyType; 123 typedef int32_t KeyType;
120 124
121 RefIDMap() {} 125 RefIDMap() {}
122 ~RefIDMap() {} 126 ~RefIDMap() {}
123 127
124 KeyType Add(RefCountedType* data) { 128 KeyType Add(RefCountedType* data) {
125 return map_.Add(new scoped_refptr<RefCountedType>(data)); 129 return map_.Add(new scoped_refptr<RefCountedType>(data));
126 } 130 }
127 131
128 RefCountedType* Lookup(KeyType id) { 132 RefCountedType* Lookup(KeyType id) {
129 scoped_refptr<RefCountedType>* ptr = map_.Lookup(id); 133 scoped_refptr<RefCountedType>* ptr = map_.Lookup(id);
(...skipping 17 matching lines...) Expand all
147 class DatabaseDispatcherHost { 151 class DatabaseDispatcherHost {
148 public: 152 public:
149 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); 153 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent);
150 ~DatabaseDispatcherHost(); 154 ~DatabaseDispatcherHost();
151 155
152 void CloseAll(); 156 void CloseAll();
153 bool OnMessageReceived(const IPC::Message& message); 157 bool OnMessageReceived(const IPC::Message& message);
154 158
155 void OnCreateObjectStore( 159 void OnCreateObjectStore(
156 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params); 160 const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params);
157 void OnDeleteObjectStore(int32 ipc_database_id, 161 void OnDeleteObjectStore(int32_t ipc_database_id,
158 int64 transaction_id, 162 int64_t transaction_id,
159 int64 object_store_id); 163 int64_t object_store_id);
160 void OnCreateTransaction( 164 void OnCreateTransaction(
161 const IndexedDBHostMsg_DatabaseCreateTransaction_Params&); 165 const IndexedDBHostMsg_DatabaseCreateTransaction_Params&);
162 void OnClose(int32 ipc_database_id); 166 void OnClose(int32_t ipc_database_id);
163 void OnVersionChangeIgnored(int32 ipc_database_id); 167 void OnVersionChangeIgnored(int32_t ipc_database_id);
164 void OnDestroyed(int32 ipc_database_id); 168 void OnDestroyed(int32_t ipc_database_id);
165 169
166 void OnGet(const IndexedDBHostMsg_DatabaseGet_Params& params); 170 void OnGet(const IndexedDBHostMsg_DatabaseGet_Params& params);
167 void OnGetAll(const IndexedDBHostMsg_DatabaseGetAll_Params& params); 171 void OnGetAll(const IndexedDBHostMsg_DatabaseGetAll_Params& params);
168 // OnPutWrapper starts on the IO thread so that it can grab BlobDataHandles 172 // OnPutWrapper starts on the IO thread so that it can grab BlobDataHandles
169 // before posting to the IDB TaskRunner for the rest of the job. 173 // before posting to the IDB TaskRunner for the rest of the job.
170 void OnPutWrapper(const IndexedDBHostMsg_DatabasePut_Params& params); 174 void OnPutWrapper(const IndexedDBHostMsg_DatabasePut_Params& params);
171 void OnPut(const IndexedDBHostMsg_DatabasePut_Params& params, 175 void OnPut(const IndexedDBHostMsg_DatabasePut_Params& params,
172 std::vector<storage::BlobDataHandle*> handles); 176 std::vector<storage::BlobDataHandle*> handles);
173 void OnSetIndexKeys( 177 void OnSetIndexKeys(
174 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params); 178 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params);
175 void OnSetIndexesReady(int32 ipc_database_id, 179 void OnSetIndexesReady(int32_t ipc_database_id,
176 int64 transaction_id, 180 int64_t transaction_id,
177 int64 object_store_id, 181 int64_t object_store_id,
178 const std::vector<int64>& ids); 182 const std::vector<int64_t>& ids);
179 void OnOpenCursor(const IndexedDBHostMsg_DatabaseOpenCursor_Params& params); 183 void OnOpenCursor(const IndexedDBHostMsg_DatabaseOpenCursor_Params& params);
180 void OnCount(const IndexedDBHostMsg_DatabaseCount_Params& params); 184 void OnCount(const IndexedDBHostMsg_DatabaseCount_Params& params);
181 void OnDeleteRange( 185 void OnDeleteRange(
182 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params); 186 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params);
183 void OnClear(int32 ipc_thread_id, 187 void OnClear(int32_t ipc_thread_id,
184 int32 ipc_callbacks_id, 188 int32_t ipc_callbacks_id,
185 int32 ipc_database_id, 189 int32_t ipc_database_id,
186 int64 transaction_id, 190 int64_t transaction_id,
187 int64 object_store_id); 191 int64_t object_store_id);
188 void OnCreateIndex( 192 void OnCreateIndex(
189 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params); 193 const IndexedDBHostMsg_DatabaseCreateIndex_Params& params);
190 void OnDeleteIndex(int32 ipc_database_id, 194 void OnDeleteIndex(int32_t ipc_database_id,
191 int64 transaction_id, 195 int64_t transaction_id,
192 int64 object_store_id, 196 int64_t object_store_id,
193 int64 index_id); 197 int64_t index_id);
194 198
195 void OnAbort(int32 ipc_database_id, int64 transaction_id); 199 void OnAbort(int32_t ipc_database_id, int64_t transaction_id);
196 void OnCommit(int32 ipc_database_id, int64 transaction_id); 200 void OnCommit(int32_t ipc_database_id, int64_t transaction_id);
197 IndexedDBDispatcherHost* parent_; 201 IndexedDBDispatcherHost* parent_;
198 IDMap<IndexedDBConnection, IDMapOwnPointer> map_; 202 IDMap<IndexedDBConnection, IDMapOwnPointer> map_;
199 WebIDBObjectIDToURLMap database_url_map_; 203 WebIDBObjectIDToURLMap database_url_map_;
200 TransactionIDToSizeMap transaction_size_map_; 204 TransactionIDToSizeMap transaction_size_map_;
201 TransactionIDToURLMap transaction_url_map_; 205 TransactionIDToURLMap transaction_url_map_;
202 TransactionIDToDatabaseIDMap transaction_database_map_; 206 TransactionIDToDatabaseIDMap transaction_database_map_;
203 207
204 private: 208 private:
205 DISALLOW_COPY_AND_ASSIGN(DatabaseDispatcherHost); 209 DISALLOW_COPY_AND_ASSIGN(DatabaseDispatcherHost);
206 }; 210 };
207 211
208 class CursorDispatcherHost { 212 class CursorDispatcherHost {
209 public: 213 public:
210 explicit CursorDispatcherHost(IndexedDBDispatcherHost* parent); 214 explicit CursorDispatcherHost(IndexedDBDispatcherHost* parent);
211 ~CursorDispatcherHost(); 215 ~CursorDispatcherHost();
212 216
213 bool OnMessageReceived(const IPC::Message& message); 217 bool OnMessageReceived(const IPC::Message& message);
214 218
215 void OnAdvance(int32 ipc_object_store_id, 219 void OnAdvance(int32_t ipc_object_store_id,
216 int32 ipc_thread_id, 220 int32_t ipc_thread_id,
217 int32 ipc_callbacks_id, 221 int32_t ipc_callbacks_id,
218 uint32 count); 222 uint32_t count);
219 void OnContinue(int32 ipc_object_store_id, 223 void OnContinue(int32_t ipc_object_store_id,
220 int32 ipc_thread_id, 224 int32_t ipc_thread_id,
221 int32 ipc_callbacks_id, 225 int32_t ipc_callbacks_id,
222 const IndexedDBKey& key, 226 const IndexedDBKey& key,
223 const IndexedDBKey& primary_key); 227 const IndexedDBKey& primary_key);
224 void OnPrefetch(int32 ipc_cursor_id, 228 void OnPrefetch(int32_t ipc_cursor_id,
225 int32 ipc_thread_id, 229 int32_t ipc_thread_id,
226 int32 ipc_callbacks_id, 230 int32_t ipc_callbacks_id,
227 int n); 231 int n);
228 void OnPrefetchReset(int32 ipc_cursor_id, 232 void OnPrefetchReset(int32_t ipc_cursor_id,
229 int used_prefetches, 233 int used_prefetches,
230 int unused_prefetches); 234 int unused_prefetches);
231 void OnDestroyed(int32 ipc_cursor_id); 235 void OnDestroyed(int32_t ipc_cursor_id);
232 236
233 IndexedDBDispatcherHost* parent_; 237 IndexedDBDispatcherHost* parent_;
234 RefIDMap<IndexedDBCursor> map_; 238 RefIDMap<IndexedDBCursor> map_;
235 239
236 private: 240 private:
237 DISALLOW_COPY_AND_ASSIGN(CursorDispatcherHost); 241 DISALLOW_COPY_AND_ASSIGN(CursorDispatcherHost);
238 }; 242 };
239 243
240 ~IndexedDBDispatcherHost() override; 244 ~IndexedDBDispatcherHost() override;
241 245
242 // Helper templates. 246 // Helper templates.
243 template <class ReturnType> 247 template <class ReturnType>
244 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map, 248 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
245 int32 ipc_return_object_id); 249 int32_t ipc_return_object_id);
246 template <class ReturnType> 250 template <class ReturnType>
247 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map, 251 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
248 int32 ipc_return_object_id); 252 int32_t ipc_return_object_id);
249 253
250 template <typename MapType> 254 template <typename MapType>
251 void DestroyObject(MapType* map, int32 ipc_object_id); 255 void DestroyObject(MapType* map, int32_t ipc_object_id);
252 256
253 // Message processing. Most of the work is delegated to the dispatcher hosts 257 // Message processing. Most of the work is delegated to the dispatcher hosts
254 // below. 258 // below.
255 void OnIDBFactoryGetDatabaseNames( 259 void OnIDBFactoryGetDatabaseNames(
256 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p); 260 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p);
257 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p); 261 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p);
258 262
259 void OnIDBFactoryDeleteDatabase( 263 void OnIDBFactoryDeleteDatabase(
260 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p); 264 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p);
261 265
(...skipping 19 matching lines...) Expand all
281 285
282 // Used to set file permissions for blob storage. 286 // Used to set file permissions for blob storage.
283 int ipc_process_id_; 287 int ipc_process_id_;
284 288
285 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 289 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
286 }; 290 };
287 291
288 } // namespace content 292 } // namespace content
289 293
290 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 294 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_database_unittest.cc ('k') | content/browser/indexed_db/indexed_db_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698