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

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

Issue 2828953002: [IndexedDB] Hold referenced to IDB::put blobs in the IDBRequest (Closed)
Patch Set: Created 3 years, 8 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>
(...skipping 15 matching lines...) Expand all
26 26
27 namespace base { 27 namespace base {
28 class SequencedTaskRunner; 28 class SequencedTaskRunner;
29 } 29 }
30 30
31 namespace url { 31 namespace url {
32 class Origin; 32 class Origin;
33 } 33 }
34 34
35 namespace content { 35 namespace content {
36 class BlobDispatcherHost;
36 class IndexedDBBlobInfo; 37 class IndexedDBBlobInfo;
37 class IndexedDBContextImpl; 38 class IndexedDBContextImpl;
38 39
39 // Handles all IndexedDB related messages from a particular renderer process. 40 // Handles all IndexedDB related messages from a particular renderer process.
40 // Constructed on UI thread, expects all other calls (including destruction) on 41 // Constructed on UI thread, expects all other calls (including destruction) on
41 // IO thread. 42 // IO thread.
42 class CONTENT_EXPORT IndexedDBDispatcherHost 43 class CONTENT_EXPORT IndexedDBDispatcherHost
43 : public ::indexed_db::mojom::Factory, 44 : public ::indexed_db::mojom::Factory,
44 public RenderProcessHostObserver { 45 public RenderProcessHostObserver {
45 public: 46 public:
(...skipping 13 matching lines...) Expand all
59 void AddCursorBinding(std::unique_ptr<::indexed_db::mojom::Cursor> cursor, 60 void AddCursorBinding(std::unique_ptr<::indexed_db::mojom::Cursor> cursor,
60 ::indexed_db::mojom::CursorAssociatedRequest request); 61 ::indexed_db::mojom::CursorAssociatedRequest request);
61 62
62 // A shortcut for accessing our context. 63 // A shortcut for accessing our context.
63 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); } 64 IndexedDBContextImpl* context() const { return indexed_db_context_.get(); }
64 storage::BlobStorageContext* blob_storage_context() const { 65 storage::BlobStorageContext* blob_storage_context() const {
65 return blob_storage_context_->context(); 66 return blob_storage_context_->context();
66 } 67 }
67 int ipc_process_id() const { return ipc_process_id_; } 68 int ipc_process_id() const { return ipc_process_id_; }
68 69
70 void SetBlobDispatcherHost(scoped_refptr<BlobDispatcherHost> host);
71
72 // Decrements the refcount for the given blob for this renderer.
73 void AckBlobRecievedFromIDB(const std::string& uuid);
74
69 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info); 75 std::string HoldBlobData(const IndexedDBBlobInfo& blob_info);
70 void DropBlobData(const std::string& uuid); 76 void DropBlobData(const std::string& uuid);
71 77
72 // Must be called on the IO thread. 78 // Must be called on the IO thread.
73 base::WeakPtr<IndexedDBDispatcherHost> AsWeakPtr() { 79 base::WeakPtr<IndexedDBDispatcherHost> AsWeakPtr() {
74 return weak_factory_.GetWeakPtr(); 80 return weak_factory_.GetWeakPtr();
75 } 81 }
76 82
77 // Called by UI thread. Used to kill outstanding bindings and weak pointers 83 // Called by UI thread. Used to kill outstanding bindings and weak pointers
78 // in callbacks. 84 // in callbacks.
(...skipping 23 matching lines...) Expand all
102 void DeleteDatabase( 108 void DeleteDatabase(
103 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, 109 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
104 const url::Origin& origin, 110 const url::Origin& origin,
105 const base::string16& name, 111 const base::string16& name,
106 bool force_close) override; 112 bool force_close) override;
107 113
108 void InvalidateWeakPtrsAndClearBindings(); 114 void InvalidateWeakPtrsAndClearBindings();
109 115
110 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 116 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
111 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; 117 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
118 // TODO(dmurph): Remove once blobs are mojo'd.
pwnall 2017/04/21 01:39:22 Would it be worth pointing to this CL in the TODO?
119 scoped_refptr<BlobDispatcherHost> blob_dispatcher_host_;
112 scoped_refptr<base::SequencedTaskRunner> idb_runner_; 120 scoped_refptr<base::SequencedTaskRunner> idb_runner_;
113 121
114 // Maps blob uuid to a pair (handle, ref count). Entry is added and/or count 122 // Maps blob uuid to a pair (handle, ref count). Entry is added and/or count
115 // is incremented in HoldBlobData(), and count is decremented and/or entry 123 // is incremented in HoldBlobData(), and count is decremented and/or entry
116 // removed in DropBlobData(). 124 // removed in DropBlobData().
117 std::map<std::string, 125 std::map<std::string,
118 std::pair<std::unique_ptr<storage::BlobDataHandle>, int>> 126 std::pair<std::unique_ptr<storage::BlobDataHandle>, int>>
119 blob_data_handle_map_; 127 blob_data_handle_map_;
120 128
121 // Used to set file permissions for blob storage. 129 // Used to set file permissions for blob storage.
(...skipping 10 matching lines...) Expand all
132 IDBThreadHelper* idb_helper_; 140 IDBThreadHelper* idb_helper_;
133 141
134 base::WeakPtrFactory<IndexedDBDispatcherHost> weak_factory_; 142 base::WeakPtrFactory<IndexedDBDispatcherHost> weak_factory_;
135 143
136 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 144 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
137 }; 145 };
138 146
139 } // namespace content 147 } // namespace content
140 148
141 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_ 149 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698