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