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

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

Issue 2727733004: [IndexedDB] Closing mojo connections when renderer quits (Closed)
Patch Set: Created 3 years, 9 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/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 18 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
19 #include "content/browser/indexed_db/database_impl.h"
19 #include "content/common/indexed_db/indexed_db.mojom.h" 20 #include "content/common/indexed_db/indexed_db.mojom.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "mojo/public/cpp/bindings/associated_binding_set.h" 22 #include "mojo/public/cpp/bindings/associated_binding_set.h"
23 #include "mojo/public/cpp/bindings/strong_associated_binding_set.h"
Reilly Grant (use Gerrit) 2017/03/03 01:51:47 This header is missing from the patch.
dmurph 2017/03/04 00:39:41 Done.
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 26
25 namespace url { 27 namespace url {
26 class Origin; 28 class Origin;
27 } 29 }
28 30
29 namespace content { 31 namespace content {
30 class IndexedDBBlobInfo; 32 class IndexedDBBlobInfo;
31 class IndexedDBCallbacks; 33 class IndexedDBCallbacks;
32 class IndexedDBContextImpl; 34 class IndexedDBContextImpl;
33 class IndexedDBDatabaseCallbacks; 35 class IndexedDBDatabaseCallbacks;
34 36
35 // Handles all IndexedDB related messages from a particular renderer process. 37 // Handles all IndexedDB related messages from a particular renderer process.
36 class IndexedDBDispatcherHost 38 class IndexedDBDispatcherHost
37 : public base::RefCountedThreadSafe<IndexedDBDispatcherHost, 39 : public base::RefCountedThreadSafe<IndexedDBDispatcherHost,
38 BrowserThread::DeleteOnIOThread>, 40 BrowserThread::DeleteOnIOThread>,
39 public ::indexed_db::mojom::Factory { 41 public ::indexed_db::mojom::Factory {
40 public: 42 public:
41 // Only call the constructor from the UI thread. 43 // Only call the constructor from the UI thread.
42 IndexedDBDispatcherHost(int ipc_process_id, 44 IndexedDBDispatcherHost(int ipc_process_id,
43 net::URLRequestContextGetter* request_context_getter, 45 net::URLRequestContextGetter* request_context_getter,
44 IndexedDBContextImpl* indexed_db_context, 46 IndexedDBContextImpl* indexed_db_context,
45 ChromeBlobStorageContext* blob_storage_context); 47 ChromeBlobStorageContext* blob_storage_context);
46 48
47 void AddBinding(::indexed_db::mojom::FactoryAssociatedRequest request); 49 void AddBinding(::indexed_db::mojom::FactoryAssociatedRequest request);
48 50
51 void AddDatabaseBinding(
52 std::unique_ptr<::indexed_db::mojom::Database> database,
53 ::indexed_db::mojom::DatabaseAssociatedRequest request);
54
55 void AddCursorBinding(std::unique_ptr<::indexed_db::mojom::Cursor> cursor,
56 ::indexed_db::mojom::CursorAssociatedRequest request);
57
58 void SetDatabaseImpl(std::unique_ptr<DatabaseImpl> database) {
Reilly Grant (use Gerrit) 2017/03/03 01:59:59 This function is unused and doesn't seem right to
dmurph 2017/03/04 00:39:41 Done.
59 database_impl_ = std::move(database);
60 }
61
49 // A shortcut for accessing our context. 62 // A shortcut for accessing our context.
50 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); } 63 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); }
51 storage::BlobStorageContext* blob_storage_context() const { 64 storage::BlobStorageContext* blob_storage_context() const {
52 return blob_storage_context_->context(); 65 return blob_storage_context_->context();
53 } 66 }
54 int ipc_process_id() const { return ipc_process_id_; } 67 int ipc_process_id() const { return ipc_process_id_; }
55 68
56 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info); 69 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info);
57 void DropBlobData(const std::string& uuid); 70 void DropBlobData(const std::string& uuid);
58 71
(...skipping 30 matching lines...) Expand all
89 const base::string16& name, 102 const base::string16& name,
90 int64_t version, 103 int64_t version,
91 int64_t transaction_id); 104 int64_t transaction_id);
92 void DeleteDatabaseOnIDBThread(scoped_refptr<IndexedDBCallbacks> callbacks, 105 void DeleteDatabaseOnIDBThread(scoped_refptr<IndexedDBCallbacks> callbacks,
93 const url::Origin& origin, 106 const url::Origin& origin,
94 const base::string16& name, 107 const base::string16& name,
95 bool force_close); 108 bool force_close);
96 109
97 void ResetDispatcherHosts(); 110 void ResetDispatcherHosts();
98 111
112 std::unique_ptr<DatabaseImpl> database_impl_;
113
99 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 114 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
100 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 115 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
101 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; 116 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
102 117
103 // Maps blob uuid to a pair (handle, ref count). Entry is added and/or count 118 // Maps blob uuid to a pair (handle, ref count). Entry is added and/or count
104 // is incremented in HoldBlobData(), and count is decremented and/or entry 119 // is incremented in HoldBlobData(), and count is decremented and/or entry
105 // removed in DropBlobData(). 120 // removed in DropBlobData().
106 std::map<std::string, 121 std::map<std::string,
107 std::pair<std::unique_ptr<storage::BlobDataHandle>, int>> 122 std::pair<std::unique_ptr<storage::BlobDataHandle>, int>>
108 blob_data_handle_map_; 123 blob_data_handle_map_;
109 124
110 // Used to set file permissions for blob storage. 125 // Used to set file permissions for blob storage.
111 const int ipc_process_id_; 126 const int ipc_process_id_;
112 127
113 mojo::AssociatedBindingSet<::indexed_db::mojom::Factory> bindings_; 128 mojo::AssociatedBindingSet<::indexed_db::mojom::Factory> bindings_;
114 129
130 mojo::StrongAssociatedBindingSet<::indexed_db::mojom::Database>
131 database_bindings_;
132
133 mojo::StrongAssociatedBindingSet<::indexed_db::mojom::Cursor>
134 cursor_bindings_;
135
115 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 136 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
116 }; 137 };
117 138
118 } // namespace content 139 } // namespace content
119 140
120 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 141 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698