OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_DATABASE_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 const Identifier& unique_identifier); | 265 const Identifier& unique_identifier); |
266 virtual ~IndexedDBDatabase(); | 266 virtual ~IndexedDBDatabase(); |
267 | 267 |
268 // May be overridden in tests. | 268 // May be overridden in tests. |
269 virtual size_t GetMaxMessageSizeInBytes() const; | 269 virtual size_t GetMaxMessageSizeInBytes() const; |
270 | 270 |
271 private: | 271 private: |
272 friend class base::RefCounted<IndexedDBDatabase>; | 272 friend class base::RefCounted<IndexedDBDatabase>; |
273 friend class IndexedDBClassFactory; | 273 friend class IndexedDBClassFactory; |
274 | 274 |
275 class OpenOrDeleteRequest; | 275 class ConnectionRequest; |
276 class OpenRequest; | 276 class OpenRequest; |
277 class DeleteRequest; | 277 class DeleteRequest; |
278 | 278 |
279 leveldb::Status OpenInternal(); | 279 leveldb::Status OpenInternal(); |
280 | 280 |
281 // Called internally when an open or delete request comes in. Processes | 281 // Called internally when an open or delete request comes in. Processes |
282 // the queue immediately if there are no other requests. | 282 // the queue immediately if there are no other requests. |
283 void AppendRequest(std::unique_ptr<OpenOrDeleteRequest> request); | 283 void AppendRequest(std::unique_ptr<ConnectionRequest> request); |
284 | 284 |
285 // Called by requests when complete. The request will be freed, so the | 285 // Called by requests when complete. The request will be freed, so the |
286 // request must do no other work after calling this. If there are pending | 286 // request must do no other work after calling this. If there are pending |
287 // requests, the queue will be synchronously processed. | 287 // requests, the queue will be synchronously processed. |
288 void RequestComplete(OpenOrDeleteRequest* request); | 288 void RequestComplete(ConnectionRequest* request); |
289 | 289 |
290 // Pop the first request from the queue and start it. | 290 // Pop the first request from the queue and start it. |
291 void ProcessRequestQueue(); | 291 void ProcessRequestQueue(); |
292 | 292 |
293 std::unique_ptr<IndexedDBConnection> CreateConnection( | 293 std::unique_ptr<IndexedDBConnection> CreateConnection( |
294 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 294 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
295 int child_process_id); | 295 int child_process_id); |
296 | 296 |
297 IndexedDBTransaction* GetTransaction(int64_t transaction_id) const; | 297 IndexedDBTransaction* GetTransaction(int64_t transaction_id) const; |
298 | 298 |
(...skipping 10 matching lines...) Expand all Loading... |
309 | 309 |
310 const Identifier identifier_; | 310 const Identifier identifier_; |
311 scoped_refptr<IndexedDBFactory> factory_; | 311 scoped_refptr<IndexedDBFactory> factory_; |
312 | 312 |
313 IndexedDBTransactionCoordinator transaction_coordinator_; | 313 IndexedDBTransactionCoordinator transaction_coordinator_; |
314 | 314 |
315 std::map<int64_t, IndexedDBTransaction*> transactions_; | 315 std::map<int64_t, IndexedDBTransaction*> transactions_; |
316 | 316 |
317 list_set<IndexedDBConnection*> connections_; | 317 list_set<IndexedDBConnection*> connections_; |
318 | 318 |
319 // This holds the first open or delete request that could not be immediately | 319 // This holds the first open or delete request that is currently being |
320 // processed. The request has already broadcast OnVersionChange if | 320 // processed. The request has already broadcast OnVersionChange if |
321 // necessary. | 321 // necessary. |
322 std::unique_ptr<OpenOrDeleteRequest> active_request_; | 322 std::unique_ptr<ConnectionRequest> active_request_; |
323 | 323 |
324 // This holds open or delete requests that are waiting for the active | 324 // This holds open or delete requests that are waiting for the active |
325 // request to be completed. The requests have not yet broadcast | 325 // request to be completed. The requests have not yet broadcast |
326 // OnVersionChange (if necessary). | 326 // OnVersionChange (if necessary). |
327 std::queue<std::unique_ptr<OpenOrDeleteRequest>> pending_requests_; | 327 std::queue<std::unique_ptr<ConnectionRequest>> pending_requests_; |
328 | 328 |
329 // The |processing_pending_requests_| flag is set while ProcessRequestQueue() | 329 // The |processing_pending_requests_| flag is set while ProcessRequestQueue() |
330 // is executing. It prevents rentrant calls if the active request completes | 330 // is executing. It prevents rentrant calls if the active request completes |
331 // synchronously. | 331 // synchronously. |
332 bool processing_pending_requests_ = false; | 332 bool processing_pending_requests_ = false; |
333 | 333 |
334 bool experimental_web_platform_features_enabled_; | 334 bool experimental_web_platform_features_enabled_; |
335 | 335 |
336 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabase); | 336 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabase); |
337 }; | 337 }; |
338 | 338 |
339 } // namespace content | 339 } // namespace content |
340 | 340 |
341 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ | 341 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ |
OLD | NEW |