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

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: Require explicit wrapping when discarding map keys. 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 template <class ReturnType> 288 template <class ReturnType>
285 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map, 289 ReturnType* GetOrTerminateProcess(IDMap<ReturnType, IDMapOwnPointer>* map,
286 int32_t ipc_return_object_id); 290 int32_t ipc_return_object_id);
287 template <class ReturnType> 291 template <class ReturnType>
288 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map, 292 ReturnType* GetOrTerminateProcess(RefIDMap<ReturnType>* map,
289 int32_t ipc_return_object_id); 293 int32_t ipc_return_object_id);
290 294
291 template <typename MapType> 295 template <typename MapType>
292 void DestroyObject(MapType* map, int32_t ipc_object_id); 296 void DestroyObject(MapType* map, int32_t ipc_object_id);
293 297
298 // indexed_db::mojom::Factory implementation:
299 void GetDatabaseNames(
300 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
301 const url::Origin& origin) override;
302 void Open(int32_t worker_thread,
303 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
304 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo
305 database_callbacks_info,
306 const url::Origin& origin,
307 const base::string16& name,
308 int64_t version,
309 int64_t transaction_id) override;
310 void DeleteDatabase(
311 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
312 const url::Origin& origin,
313 const base::string16& name) override;
314
315 void GetDatabaseNamesOnIDBThread(scoped_refptr<IndexedDBCallbacks> callbacks,
316 const url::Origin& origin);
317 void OpenOnIDBThread(
318 scoped_refptr<IndexedDBCallbacks> callbacks,
319 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
320 const url::Origin& origin,
321 const base::string16& name,
322 int64_t version,
323 int64_t transaction_id);
324 void DeleteDatabaseOnIDBThread(scoped_refptr<IndexedDBCallbacks> callbacks,
325 const url::Origin& origin,
326 const base::string16& name);
327
294 // Message processing. Most of the work is delegated to the dispatcher hosts 328 // Message processing. Most of the work is delegated to the dispatcher hosts
295 // below. 329 // below.
296 void OnIDBFactoryGetDatabaseNames(
297 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& p);
298 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p);
299
300 void OnIDBFactoryDeleteDatabase(
301 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p);
302
303 void OnAckReceivedBlobs(const std::vector<std::string>& uuids); 330 void OnAckReceivedBlobs(const std::vector<std::string>& uuids);
304 void OnPutHelper( 331 void OnPutHelper(
305 const IndexedDBHostMsg_DatabasePut_Params& params, 332 const IndexedDBHostMsg_DatabasePut_Params& params,
306 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles); 333 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles);
307 334
308 void ResetDispatcherHosts(); 335 void ResetDispatcherHosts();
309 void DropBlobData(const std::string& uuid); 336 void DropBlobData(const std::string& uuid);
310 337
311 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 338 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
312 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 339 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
(...skipping 13 matching lines...) Expand all
326 353
327 // Used to set file permissions for blob storage. 354 // Used to set file permissions for blob storage.
328 int ipc_process_id_; 355 int ipc_process_id_;
329 356
330 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 357 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
331 }; 358 };
332 359
333 } // namespace content 360 } // namespace content
334 361
335 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 362 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698