| 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 MOJO_SERVICES_CATALOG_FACTORY_H_ | |
| 6 #define MOJO_SERVICES_CATALOG_FACTORY_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "mojo/public/cpp/bindings/binding.h" | |
| 15 #include "mojo/services/catalog/public/interfaces/catalog.mojom.h" | |
| 16 #include "mojo/services/catalog/public/interfaces/resolver.mojom.h" | |
| 17 #include "mojo/services/catalog/types.h" | |
| 18 #include "services/shell/public/cpp/shell_client.h" | |
| 19 #include "services/shell/public/interfaces/shell_client.mojom.h" | |
| 20 #include "services/shell/public/interfaces/shell_resolver.mojom.h" | |
| 21 | |
| 22 namespace base { | |
| 23 class TaskRunner; | |
| 24 } | |
| 25 | |
| 26 namespace mojo{ | |
| 27 class ShellConnection; | |
| 28 } | |
| 29 | |
| 30 namespace catalog { | |
| 31 | |
| 32 class Catalog; | |
| 33 class ManifestProvider; | |
| 34 class Store; | |
| 35 | |
| 36 // Creates and owns an instance of the catalog. Exposes a ShellClientPtr that | |
| 37 // can be passed to the Shell, potentially in a different process. | |
| 38 class Factory | |
| 39 : public mojo::ShellClient, | |
| 40 public mojo::InterfaceFactory<mojom::Catalog>, | |
| 41 public mojo::InterfaceFactory<mojom::Resolver>, | |
| 42 public mojo::InterfaceFactory<mojo::shell::mojom::ShellResolver> { | |
| 43 public: | |
| 44 // |manifest_provider| may be null. | |
| 45 Factory(base::TaskRunner* file_task_runner, | |
| 46 scoped_ptr<Store> store, | |
| 47 ManifestProvider* manifest_provider); | |
| 48 ~Factory() override; | |
| 49 | |
| 50 mojo::shell::mojom::ShellClientPtr TakeShellClient(); | |
| 51 | |
| 52 private: | |
| 53 // mojo::ShellClient: | |
| 54 bool AcceptConnection(mojo::Connection* connection) override; | |
| 55 | |
| 56 // mojo::InterfaceFactory<mojom::Resolver>: | |
| 57 void Create(mojo::Connection* connection, | |
| 58 mojom::ResolverRequest request) override; | |
| 59 | |
| 60 // mojo::InterfaceFactory<mojo::shell::mojom::ShellResolver>: | |
| 61 void Create(mojo::Connection* connection, | |
| 62 mojo::shell::mojom::ShellResolverRequest request) override; | |
| 63 | |
| 64 // mojo::InterfaceFactory<mojom::Catalog>: | |
| 65 void Create(mojo::Connection* connection, | |
| 66 mojom::CatalogRequest request) override; | |
| 67 | |
| 68 Catalog* GetCatalogForUserId(const std::string& user_id); | |
| 69 | |
| 70 base::TaskRunner* const file_task_runner_; | |
| 71 scoped_ptr<Store> store_; | |
| 72 ManifestProvider* const manifest_provider_; | |
| 73 | |
| 74 mojo::shell::mojom::ShellClientPtr shell_client_; | |
| 75 scoped_ptr<mojo::ShellConnection> shell_connection_; | |
| 76 | |
| 77 std::map<std::string, scoped_ptr<Catalog>> catalogs_; | |
| 78 | |
| 79 EntryCache system_catalog_; | |
| 80 | |
| 81 base::WeakPtrFactory<Factory> weak_factory_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(Factory); | |
| 84 }; | |
| 85 | |
| 86 } // namespace catalog | |
| 87 | |
| 88 #endif // MOJO_SERVICES_CATALOG_FACTORY_H_ | |
| OLD | NEW |