OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_INDEXED_DB_DATABASE_FACTORY_IMPL_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_DATABASE_FACTORY_IMPL_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <set> |
| 10 #include <string> |
| 11 |
| 12 #include "Source/modules/indexeddb/indexed_db.mojom.h" |
| 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/process/process_handle.h" |
| 17 #include "content/browser/bad_message.h" |
| 18 #include "content/public/browser/browser_context.h" |
| 19 #include "mojo/public/cpp/bindings/binding_set.h" |
| 20 |
| 21 namespace net { |
| 22 class URLRequestContextGetter; |
| 23 } |
| 24 |
| 25 namespace shell { |
| 26 class InterfaceRegistry; |
| 27 } |
| 28 |
| 29 namespace content { |
| 30 |
| 31 class IndexedDBConnection; |
| 32 class IndexedDBContextImpl; |
| 33 class IndexedDBDatabaseError; |
| 34 struct IndexedDBDatabaseMetadata; |
| 35 |
| 36 class DatabaseFactoryImpl : public ::indexed_db::mojom::DatabaseFactory, |
| 37 public base::SupportsWeakPtr<DatabaseFactoryImpl> { |
| 38 public: |
| 39 // TODO(cmumford): Keep Create()? |
| 40 static std::unique_ptr<DatabaseFactoryImpl> Create( |
| 41 IndexedDBContextImpl* indexed_db_context, |
| 42 net::URLRequestContextGetter* url_request_context_getter, |
| 43 int render_process_host_id); |
| 44 DatabaseFactoryImpl(IndexedDBContextImpl* indexed_db_context, |
| 45 net::URLRequestContextGetter* url_request_context_getter, |
| 46 int render_process_host_id); |
| 47 ~DatabaseFactoryImpl() override; |
| 48 |
| 49 void AddMojoService(shell::InterfaceRegistry* registry); |
| 50 void Bind(::indexed_db::mojom::DatabaseFactoryRequest request); |
| 51 |
| 52 private: |
| 53 void CrashRendererAndClosePipe(bad_message::BadMessageReason reason); |
| 54 |
| 55 RenderProcessHost* GetRenderProcessHost(); |
| 56 |
| 57 void OnOpenResult(const base::TimeTicks& begin_time, |
| 58 const OpenCallback& mojo_callback, |
| 59 std::unique_ptr<IndexedDBConnection> connection, |
| 60 const IndexedDBDatabaseMetadata& metadata, |
| 61 const IndexedDBDatabaseError& error); |
| 62 |
| 63 // indexed_db::mojom::DatabaseFactory: |
| 64 void GetDatabaseNames(const url::Origin& origin) override; |
| 65 |
| 66 void Open(const std::string& name, |
| 67 int64_t version, |
| 68 int64_t transaction_id, |
| 69 const url::Origin& origin, |
| 70 ::indexed_db::mojom::OpenRequestObserverPtr open_observer, |
| 71 ::indexed_db::mojom::DatabaseObserverPtr database_handler, |
| 72 const OpenCallback& callback) override; |
| 73 |
| 74 void DeleteDatabase(const std::string& name, |
| 75 const url::Origin& origin) override; |
| 76 |
| 77 void AddMojoServiceOnIDBThread(shell::InterfaceRegistry* registry); |
| 78 |
| 79 // Used to set file permissions for blob storage. |
| 80 int render_process_host_id_; |
| 81 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
| 82 // Determine or document lifetime of getter. |
| 83 net::URLRequestContextGetter* request_context_getter_; |
| 84 std::set<std::unique_ptr<IndexedDBConnection>> connections_; |
| 85 mojo::BindingSet<::indexed_db::mojom::DatabaseFactory> binding_; |
| 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(DatabaseFactoryImpl); |
| 88 }; |
| 89 |
| 90 } // namespace content |
| 91 |
| 92 #endif // CONTENT_BROWSER_INDEXED_DB_DATABASE_FACTORY_IMPL_H_ |
OLD | NEW |