| OLD | NEW |
| 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> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 IndexedDBDispatcherHost(int ipc_process_id, | 43 IndexedDBDispatcherHost(int ipc_process_id, |
| 44 net::URLRequestContextGetter* request_context_getter, | 44 net::URLRequestContextGetter* request_context_getter, |
| 45 IndexedDBContextImpl* indexed_db_context, | 45 IndexedDBContextImpl* indexed_db_context, |
| 46 ChromeBlobStorageContext* blob_storage_context); | 46 ChromeBlobStorageContext* blob_storage_context); |
| 47 | 47 |
| 48 // BrowserMessageFilter implementation. | 48 // BrowserMessageFilter implementation. |
| 49 void OnChannelClosing() override; | 49 void OnChannelClosing() override; |
| 50 void OnDestruct() const override; | 50 void OnDestruct() const override; |
| 51 bool OnMessageReceived(const IPC::Message& message) override; | 51 bool OnMessageReceived(const IPC::Message& message) override; |
| 52 | 52 |
| 53 void FinishTransaction(int64_t host_transaction_id, bool committed); | |
| 54 | |
| 55 // A shortcut for accessing our context. | 53 // A shortcut for accessing our context. |
| 56 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); } | 54 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); } |
| 57 storage::BlobStorageContext* blob_storage_context() const { | 55 storage::BlobStorageContext* blob_storage_context() const { |
| 58 return blob_storage_context_->context(); | 56 return blob_storage_context_->context(); |
| 59 } | 57 } |
| 60 int ipc_process_id() const { return ipc_process_id_; } | 58 int ipc_process_id() const { return ipc_process_id_; } |
| 61 | 59 |
| 62 bool RegisterTransactionId(int64_t host_transaction_id, | |
| 63 const url::Origin& origin); | |
| 64 bool GetTransactionSize(int64_t host_transaction_id, | |
| 65 int64_t* transaction_size); | |
| 66 void AddToTransaction(int64_t host_transaction_id, int64_t value_length); | |
| 67 | |
| 68 // These are called to map a 32-bit front-end (renderer-specific) transaction | |
| 69 // id to and from a back-end ("host") transaction id that encodes the process | |
| 70 // id in the high 32 bits. The mapping is host-specific and ids are validated. | |
| 71 int64_t HostTransactionId(int64_t transaction_id); | |
| 72 int64_t RendererTransactionId(int64_t host_transaction_id); | |
| 73 | |
| 74 // These are called to decode a host transaction ID, for diagnostic purposes. | |
| 75 static uint32_t TransactionIdToRendererTransactionId( | |
| 76 int64_t host_transaction_id); | |
| 77 static uint32_t TransactionIdToProcessId(int64_t host_transaction_id); | |
| 78 | |
| 79 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info); | 60 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info); |
| 80 void DropBlobData(const std::string& uuid); | 61 void DropBlobData(const std::string& uuid); |
| 81 | 62 |
| 82 // True if the channel is closing/closed and outstanding requests | 63 // True if the channel is closing/closed and outstanding requests |
| 83 // can be abandoned. Only access on IndexedDB thread. | 64 // can be abandoned. Only access on IndexedDB thread. |
| 84 bool IsOpen() const; | 65 bool IsOpen() const; |
| 85 | 66 |
| 86 private: | 67 private: |
| 87 // Friends to enable OnDestruct() delegation. | 68 // Friends to enable OnDestruct() delegation. |
| 88 friend class BrowserThread; | 69 friend class BrowserThread; |
| 89 friend class base::DeleteHelper<IndexedDBDispatcherHost>; | 70 friend class base::DeleteHelper<IndexedDBDispatcherHost>; |
| 90 | 71 |
| 91 // Used in nested classes. | |
| 92 typedef std::map<int64_t, int64_t> TransactionIDToSizeMap; | |
| 93 typedef std::map<int64_t, url::Origin> TransactionIDToOriginMap; | |
| 94 | |
| 95 ~IndexedDBDispatcherHost() override; | 72 ~IndexedDBDispatcherHost() override; |
| 96 | 73 |
| 97 // indexed_db::mojom::Factory implementation: | 74 // indexed_db::mojom::Factory implementation: |
| 98 void GetDatabaseNames( | 75 void GetDatabaseNames( |
| 99 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, | 76 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| 100 const url::Origin& origin) override; | 77 const url::Origin& origin) override; |
| 101 void Open(::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, | 78 void Open(::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, |
| 102 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo | 79 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo |
| 103 database_callbacks_info, | 80 database_callbacks_info, |
| 104 const url::Origin& origin, | 81 const url::Origin& origin, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 131 | 108 |
| 132 // Maps blob uuid to a pair (handle, ref count). Entry is added and/or count | 109 // Maps blob uuid to a pair (handle, ref count). Entry is added and/or count |
| 133 // is incremented in HoldBlobData(), and count is decremented and/or entry | 110 // is incremented in HoldBlobData(), and count is decremented and/or entry |
| 134 // removed in DropBlobData(). | 111 // removed in DropBlobData(). |
| 135 std::map<std::string, | 112 std::map<std::string, |
| 136 std::pair<std::unique_ptr<storage::BlobDataHandle>, int>> | 113 std::pair<std::unique_ptr<storage::BlobDataHandle>, int>> |
| 137 blob_data_handle_map_; | 114 blob_data_handle_map_; |
| 138 | 115 |
| 139 // Only access on IndexedDB thread. | 116 // Only access on IndexedDB thread. |
| 140 bool is_open_ = true; | 117 bool is_open_ = true; |
| 141 TransactionIDToSizeMap transaction_size_map_; | |
| 142 TransactionIDToOriginMap transaction_origin_map_; | |
| 143 | 118 |
| 144 // Used to set file permissions for blob storage. | 119 // Used to set file permissions for blob storage. |
| 145 int ipc_process_id_; | 120 int ipc_process_id_; |
| 146 | 121 |
| 147 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); | 122 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); |
| 148 }; | 123 }; |
| 149 | 124 |
| 150 } // namespace content | 125 } // namespace content |
| 151 | 126 |
| 152 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ | 127 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ |
| OLD | NEW |