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

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

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Rebase over the Blink reformatting. Created 4 years, 2 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> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/id_map.h" 16 #include "base/id_map.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 20 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
21 #include "content/common/indexed_db/indexed_db.mojom.h"
22 #include "content/public/browser/browser_associated_interface.h"
21 #include "content/public/browser/browser_message_filter.h" 23 #include "content/public/browser/browser_message_filter.h"
22 #include "net/url_request/url_request_context_getter.h" 24 #include "net/url_request/url_request_context_getter.h"
23 #include "storage/browser/blob/blob_data_handle.h" 25 #include "storage/browser/blob/blob_data_handle.h"
24 #include "storage/browser/quota/quota_manager.h" 26 #include "storage/browser/quota/quota_manager.h"
25 #include "storage/common/quota/quota_status_code.h" 27 #include "storage/common/quota/quota_status_code.h"
26 #include "url/gurl.h" 28 #include "url/gurl.h"
27 29
28 struct IndexedDBDatabaseMetadata; 30 struct IndexedDBDatabaseMetadata;
29 struct IndexedDBHostMsg_DatabaseCount_Params; 31 struct IndexedDBHostMsg_DatabaseCount_Params;
30 struct IndexedDBHostMsg_DatabaseCreateIndex_Params; 32 struct IndexedDBHostMsg_DatabaseCreateIndex_Params;
(...skipping 11 matching lines...) Expand all
42 struct IndexedDBHostMsg_FactoryOpen_Params; 44 struct IndexedDBHostMsg_FactoryOpen_Params;
43 struct IndexedDBMsg_Observation; 45 struct IndexedDBMsg_Observation;
44 struct IndexedDBMsg_ObserverChanges; 46 struct IndexedDBMsg_ObserverChanges;
45 47
46 namespace url { 48 namespace url {
47 class Origin; 49 class Origin;
48 } 50 }
49 51
50 namespace content { 52 namespace content {
51 class IndexedDBBlobInfo; 53 class IndexedDBBlobInfo;
54 class IndexedDBCallbacks;
52 class IndexedDBConnection; 55 class IndexedDBConnection;
53 class IndexedDBContextImpl; 56 class IndexedDBContextImpl;
54 class IndexedDBCursor; 57 class IndexedDBCursor;
58 class IndexedDBDatabaseCallbacks;
55 class IndexedDBKey; 59 class IndexedDBKey;
56 class IndexedDBKeyPath; 60 class IndexedDBKeyPath;
57 class IndexedDBKeyRange; 61 class IndexedDBKeyRange;
58 class IndexedDBObservation; 62 class IndexedDBObservation;
59 class IndexedDBObserverChanges; 63 class IndexedDBObserverChanges;
60 struct IndexedDBDatabaseMetadata; 64 struct IndexedDBDatabaseMetadata;
61 65
62 // Handles all IndexedDB related messages from a particular renderer process. 66 // Handles all IndexedDB related messages from a particular renderer process.
63 class IndexedDBDispatcherHost : public BrowserMessageFilter { 67 class IndexedDBDispatcherHost
68 : public BrowserMessageFilter,
69 public BrowserAssociatedInterface<::indexed_db::mojom::Factory>,
70 public ::indexed_db::mojom::Factory {
64 public: 71 public:
65 // Only call the constructor from the UI thread. 72 // Only call the constructor from the UI thread.
66 IndexedDBDispatcherHost(int ipc_process_id, 73 IndexedDBDispatcherHost(int ipc_process_id,
67 net::URLRequestContextGetter* request_context_getter, 74 net::URLRequestContextGetter* request_context_getter,
68 IndexedDBContextImpl* indexed_db_context, 75 IndexedDBContextImpl* indexed_db_context,
69 ChromeBlobStorageContext* blob_storage_context); 76 ChromeBlobStorageContext* blob_storage_context);
70 77
71 static ::IndexedDBDatabaseMetadata ConvertMetadata(
72 const content::IndexedDBDatabaseMetadata& metadata);
73 static IndexedDBMsg_ObserverChanges ConvertObserverChanges( 78 static IndexedDBMsg_ObserverChanges ConvertObserverChanges(
74 std::unique_ptr<IndexedDBObserverChanges> changes); 79 std::unique_ptr<IndexedDBObserverChanges> changes);
75 static IndexedDBMsg_Observation ConvertObservation( 80 static IndexedDBMsg_Observation ConvertObservation(
76 const IndexedDBObservation* observation); 81 const IndexedDBObservation* observation);
77 82
78 // BrowserMessageFilter implementation. 83 // BrowserMessageFilter implementation.
79 void OnChannelClosing() override; 84 void OnChannelClosing() override;
80 void OnDestruct() const override; 85 void OnDestruct() const override;
81 base::TaskRunner* OverrideTaskRunnerForMessage( 86 base::TaskRunner* OverrideTaskRunnerForMessage(
82 const IPC::Message& message) override; 87 const IPC::Message& message) override;
83 bool OnMessageReceived(const IPC::Message& message) override; 88 bool OnMessageReceived(const IPC::Message& message) override;
84 89
85 void FinishTransaction(int64_t host_transaction_id, bool committed); 90 void FinishTransaction(int64_t host_transaction_id, bool committed);
86 91
87 // A shortcut for accessing our context. 92 // A shortcut for accessing our context.
88 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); } 93 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); }
89 storage::BlobStorageContext* blob_storage_context() const { 94 storage::BlobStorageContext* blob_storage_context() const {
90 return blob_storage_context_->context(); 95 return blob_storage_context_->context();
91 } 96 }
92 97
93 // IndexedDBCallbacks call these methods to add the results into the 98 // IndexedDBCallbacks call these methods to add the results into the
94 // applicable map. See below for more details. 99 // applicable map. See below for more details.
95 int32_t Add(IndexedDBCursor* cursor); 100 int32_t Add(IndexedDBCursor* cursor);
96 int32_t Add(IndexedDBConnection* connection, 101 int32_t Add(IndexedDBConnection* connection,
97 int32_t ipc_thread_id,
98 const url::Origin& origin); 102 const url::Origin& origin);
99 103
100 void RegisterTransactionId(int64_t host_transaction_id, 104 void RegisterTransactionId(int64_t host_transaction_id,
101 const url::Origin& origin); 105 const url::Origin& origin);
102 106
103 IndexedDBCursor* GetCursorFromId(int32_t ipc_cursor_id); 107 IndexedDBCursor* GetCursorFromId(int32_t ipc_cursor_id);
104 108
105 // These are called to map a 32-bit front-end (renderer-specific) transaction 109 // These are called to map a 32-bit front-end (renderer-specific) transaction
106 // id to and from a back-end ("host") transaction id that encodes the process 110 // id to and from a back-end ("host") transaction id that encodes the process
107 // id in the high 32 bits. The mapping is host-specific and ids are validated. 111 // id in the high 32 bits. The mapping is host-specific and ids are validated.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 template <class ReturnType> 284 template <class ReturnType>
281 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map, 285 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
282 int32_t ipc_return_object_id); 286 int32_t ipc_return_object_id);
283 template <class ReturnType> 287 template <class ReturnType>
284 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map, 288 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
285 int32_t ipc_return_object_id); 289 int32_t ipc_return_object_id);
286 290
287 template <typename MapType> 291 template <typename MapType>
288 void DestroyObject(MapType* map, int32_t ipc_object_id); 292 void DestroyObject(MapType* map, int32_t ipc_object_id);
289 293
294 // indexed_db::mojom::Factory implementation:
295 void GetDatabaseNames(
296 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
297 const url::Origin& origin) override;
298 void Open(int32_t worker_thread,
299 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
300 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo
301 database_callbacks_info,
302 const url::Origin& origin,
303 const base::string16& name,
304 int64_t version,
305 int64_t transaction_id) override;
306 void DeleteDatabase(
307 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
308 const url::Origin& origin,
309 const base::string16& name) override;
310
311 void GetDatabaseNamesOnIDBThread(scoped_refptr<IndexedDBCallbacks> callbacks,
312 const url::Origin& origin);
313 void OpenOnIDBThread(
314 scoped_refptr<IndexedDBCallbacks> callbacks,
315 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
316 const url::Origin& origin,
317 const base::string16& name,
318 int64_t version,
319 int64_t transaction_id);
320 void DeleteDatabaseOnIDBThread(scoped_refptr<IndexedDBCallbacks> callbacks,
321 const url::Origin& origin,
322 const base::string16& name);
323
290 // Message processing. Most of the work is delegated to the dispatcher hosts 324 // Message processing. Most of the work is delegated to the dispatcher hosts
291 // below. 325 // below.
292 void OnIDBFactoryGetDatabaseNames(
293 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p);
294 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p);
295
296 void OnIDBFactoryDeleteDatabase(
297 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p);
298
299 void OnAckReceivedBlobs(const std::vector<std::string>& uuids); 326 void OnAckReceivedBlobs(const std::vector<std::string>& uuids);
300 void OnPutHelper( 327 void OnPutHelper(
301 const IndexedDBHostMsg_DatabasePut_Params& params, 328 const IndexedDBHostMsg_DatabasePut_Params& params,
302 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles); 329 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles);
303 330
304 void ResetDispatcherHosts(); 331 void ResetDispatcherHosts();
305 void DropBlobData(const std::string& uuid); 332 void DropBlobData(const std::string& uuid);
306 333
307 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 334 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
308 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 335 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
(...skipping 12 matching lines...) Expand all
321 348
322 // Used to set file permissions for blob storage. 349 // Used to set file permissions for blob storage.
323 int ipc_process_id_; 350 int ipc_process_id_;
324 351
325 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 352 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
326 }; 353 };
327 354
328 } // namespace content 355 } // namespace content
329 356
330 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 357 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698