Index: content/browser/indexed_db/indexed_db_dispatcher_host.h |
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.h b/content/browser/indexed_db/indexed_db_dispatcher_host.h |
index e24caf71e26f8294c4ca2ba6b4cf471dd6d7c83d..c64c71f5a9966d9f8271f203bf261d9c278b829d 100644 |
--- a/content/browser/indexed_db/indexed_db_dispatcher_host.h |
+++ b/content/browser/indexed_db/indexed_db_dispatcher_host.h |
@@ -18,34 +18,47 @@ |
#include "content/browser/blob_storage/chrome_blob_storage_context.h" |
#include "content/common/indexed_db/indexed_db.mojom.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/render_process_host_observer.h" |
#include "mojo/public/cpp/bindings/associated_binding_set.h" |
+#include "mojo/public/cpp/bindings/strong_associated_binding_set.h" |
#include "net/url_request/url_request_context_getter.h" |
#include "storage/browser/blob/blob_data_handle.h" |
+namespace base { |
+class SequencedTaskRunner; |
+} |
+ |
namespace url { |
class Origin; |
} |
namespace content { |
class IndexedDBBlobInfo; |
-class IndexedDBCallbacks; |
class IndexedDBContextImpl; |
-class IndexedDBDatabaseCallbacks; |
// Handles all IndexedDB related messages from a particular renderer process. |
-class IndexedDBDispatcherHost |
- : public base::RefCountedThreadSafe<IndexedDBDispatcherHost, |
- BrowserThread::DeleteOnIOThread>, |
- public ::indexed_db::mojom::Factory { |
+// Constructed on UI thread, expects all other calls (including destruction) on |
+// IO thread. |
+class CONTENT_EXPORT IndexedDBDispatcherHost |
+ : public ::indexed_db::mojom::Factory, |
+ public RenderProcessHostObserver { |
public: |
// Only call the constructor from the UI thread. |
- IndexedDBDispatcherHost(int ipc_process_id, |
- net::URLRequestContextGetter* request_context_getter, |
- IndexedDBContextImpl* indexed_db_context, |
- ChromeBlobStorageContext* blob_storage_context); |
+ IndexedDBDispatcherHost( |
+ int ipc_process_id, |
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
+ scoped_refptr<IndexedDBContextImpl> indexed_db_context, |
+ scoped_refptr<ChromeBlobStorageContext> blob_storage_context); |
void AddBinding(::indexed_db::mojom::FactoryAssociatedRequest request); |
+ void AddDatabaseBinding( |
+ std::unique_ptr<::indexed_db::mojom::Database> database, |
+ ::indexed_db::mojom::DatabaseAssociatedRequest request); |
+ |
+ void AddCursorBinding(std::unique_ptr<::indexed_db::mojom::Cursor> cursor, |
+ ::indexed_db::mojom::CursorAssociatedRequest request); |
+ |
// A shortcut for accessing our context. |
IndexedDBContextImpl* context() const { return indexed_db_context_.get(); } |
storage::BlobStorageContext* blob_storage_context() const { |
@@ -56,7 +69,19 @@ class IndexedDBDispatcherHost |
std::string HoldBlobData(const IndexedDBBlobInfo& blob_info); |
void DropBlobData(const std::string& uuid); |
+ // Must be called on the IO thread. |
+ base::WeakPtr<IndexedDBDispatcherHost> AsWeakPtr() { |
+ return weak_factory_.GetWeakPtr(); |
+ } |
+ |
+ // Called by UI thread. Used to kill outstanding bindings and weak pointers |
+ // in callbacks. |
+ void RenderProcessExited(RenderProcessHost* host, |
+ base::TerminationStatus status, |
+ int exit_code) override; |
+ |
private: |
+ class IDBThreadHelper; |
// Friends to enable OnDestruct() delegation. |
friend class BrowserThread; |
friend class base::DeleteHelper<IndexedDBDispatcherHost>; |
@@ -80,25 +105,11 @@ class IndexedDBDispatcherHost |
const base::string16& name, |
bool force_close) override; |
- void GetDatabaseNamesOnIDBThread(scoped_refptr<IndexedDBCallbacks> callbacks, |
- const url::Origin& origin); |
- void OpenOnIDBThread( |
- scoped_refptr<IndexedDBCallbacks> callbacks, |
- scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
- const url::Origin& origin, |
- const base::string16& name, |
- int64_t version, |
- int64_t transaction_id); |
- void DeleteDatabaseOnIDBThread(scoped_refptr<IndexedDBCallbacks> callbacks, |
- const url::Origin& origin, |
- const base::string16& name, |
- bool force_close); |
+ void InvalidateWeakPtrsAndClearBindings(); |
- void ResetDispatcherHosts(); |
- |
- scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
+ scoped_refptr<base::SequencedTaskRunner> idb_runner_; |
// Maps blob uuid to a pair (handle, ref count). Entry is added and/or count |
// is incremented in HoldBlobData(), and count is decremented and/or entry |
@@ -112,6 +123,16 @@ class IndexedDBDispatcherHost |
mojo::AssociatedBindingSet<::indexed_db::mojom::Factory> bindings_; |
+ mojo::StrongAssociatedBindingSet<::indexed_db::mojom::Database> |
+ database_bindings_; |
+ |
+ mojo::StrongAssociatedBindingSet<::indexed_db::mojom::Cursor> |
+ cursor_bindings_; |
+ |
+ IDBThreadHelper* idb_helper_; |
+ |
+ base::WeakPtrFactory<IndexedDBDispatcherHost> weak_factory_; |
+ |
DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); |
}; |