Chromium Code Reviews| 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_CATALOG_H_ | 5 #ifndef MOJO_SERVICES_CATALOG_CATALOG_H_ |
| 6 #define MOJO_SERVICES_CATALOG_CATALOG_H_ | 6 #define MOJO_SERVICES_CATALOG_CATALOG_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/string_piece.h" | |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "mojo/public/cpp/bindings/binding_set.h" | 13 #include "mojo/public/cpp/bindings/binding_set.h" |
| 13 #include "mojo/services/catalog/entry.h" | 14 #include "mojo/services/catalog/entry.h" |
| 14 #include "mojo/services/catalog/public/interfaces/catalog.mojom.h" | 15 #include "mojo/services/catalog/public/interfaces/catalog.mojom.h" |
| 15 #include "mojo/services/catalog/public/interfaces/resolver.mojom.h" | 16 #include "mojo/services/catalog/public/interfaces/resolver.mojom.h" |
| 16 #include "mojo/services/catalog/reader.h" | 17 #include "mojo/services/catalog/reader.h" |
| 17 #include "mojo/services/catalog/store.h" | 18 #include "mojo/services/catalog/store.h" |
| 18 #include "mojo/shell/public/cpp/interface_factory.h" | 19 #include "mojo/shell/public/cpp/interface_factory.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 catalog { | 22 namespace catalog { |
| 22 | 23 |
| 23 class Store; | 24 class Store; |
| 24 | 25 |
| 25 class Catalog : public mojom::Resolver, | 26 class Catalog : public mojom::Resolver, |
| 26 public mojo::shell::mojom::ShellResolver, | 27 public mojo::shell::mojom::ShellResolver, |
| 27 public mojom::Catalog { | 28 public mojom::Catalog { |
| 28 public: | 29 public: |
| 29 Catalog(base::TaskRunner* blocking_pool, scoped_ptr<Store> store); | 30 class Delegate { |
|
Ben Goodger (Google)
2016/03/24 22:53:54
top level class, ManifestProvider.
| |
| 31 public: | |
| 32 virtual ~Delegate() {} | |
| 33 virtual bool GetApplicationManifest(const base::StringPiece& name, | |
| 34 std::string* manifest_contents) = 0; | |
| 35 }; | |
| 36 | |
| 37 // |delegate| may be null. | |
| 38 Catalog(base::TaskRunner* blocking_pool, | |
| 39 scoped_ptr<Store> store, | |
| 40 Delegate* delegate); | |
| 30 ~Catalog() override; | 41 ~Catalog() override; |
| 31 | 42 |
| 32 void BindResolver(mojom::ResolverRequest request); | 43 void BindResolver(mojom::ResolverRequest request); |
| 33 void BindShellResolver(mojo::shell::mojom::ShellResolverRequest request); | 44 void BindShellResolver(mojo::shell::mojom::ShellResolverRequest request); |
| 34 void BindCatalog(mojom::CatalogRequest request); | 45 void BindCatalog(mojom::CatalogRequest request); |
| 35 | 46 |
| 36 private: | 47 private: |
| 37 using MojoNameAliasMap = | 48 using MojoNameAliasMap = |
| 38 std::map<std::string, std::pair<std::string, std::string>>; | 49 std::map<std::string, std::pair<std::string, std::string>>; |
| 39 | 50 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 const ResolveMojoNameCallback& callback, | 87 const ResolveMojoNameCallback& callback, |
| 77 scoped_ptr<Entry> entry); | 88 scoped_ptr<Entry> entry); |
| 78 void OnReadEntryImpl(const std::string& name, | 89 void OnReadEntryImpl(const std::string& name, |
| 79 const ResolveMojoNameCallback& callback, | 90 const ResolveMojoNameCallback& callback, |
| 80 scoped_ptr<Entry> entry); | 91 scoped_ptr<Entry> entry); |
| 81 | 92 |
| 82 // Construct a catalog entry from |dictionary|. | 93 // Construct a catalog entry from |dictionary|. |
| 83 scoped_ptr<Entry> DeserializeApplication( | 94 scoped_ptr<Entry> DeserializeApplication( |
| 84 const base::DictionaryValue* dictionary); | 95 const base::DictionaryValue* dictionary); |
| 85 | 96 |
| 97 Delegate* delegate_; | |
| 98 | |
| 86 scoped_ptr<Reader> reader_; | 99 scoped_ptr<Reader> reader_; |
| 87 base::FilePath package_path_; | 100 base::FilePath package_path_; |
| 88 | 101 |
| 89 mojo::BindingSet<mojom::Resolver> resolver_bindings_; | 102 mojo::BindingSet<mojom::Resolver> resolver_bindings_; |
| 90 mojo::BindingSet<mojo::shell::mojom::ShellResolver> shell_resolver_bindings_; | 103 mojo::BindingSet<mojo::shell::mojom::ShellResolver> shell_resolver_bindings_; |
| 91 mojo::BindingSet<mojom::Catalog> catalog_bindings_; | 104 mojo::BindingSet<mojom::Catalog> catalog_bindings_; |
| 92 | 105 |
| 93 scoped_ptr<Store> store_; | 106 scoped_ptr<Store> store_; |
| 94 std::map<std::string, Entry> catalog_; | 107 std::map<std::string, Entry> catalog_; |
| 95 | 108 |
| 96 // Used when an app handles multiple names. Maps from app (as name) to name of | 109 // Used when an app handles multiple names. Maps from app (as name) to name of |
| 97 // app that is responsible for handling it. The value is a pair of the name of | 110 // app that is responsible for handling it. The value is a pair of the name of |
| 98 // the handler along with a qualifier. | 111 // the handler along with a qualifier. |
| 99 MojoNameAliasMap mojo_name_aliases_; | 112 MojoNameAliasMap mojo_name_aliases_; |
| 100 | 113 |
| 101 std::map<std::string, std::string> qualifiers_; | 114 std::map<std::string, std::string> qualifiers_; |
| 102 | 115 |
| 103 base::WeakPtrFactory<Catalog> weak_factory_; | 116 base::WeakPtrFactory<Catalog> weak_factory_; |
| 104 | 117 |
| 105 DISALLOW_COPY_AND_ASSIGN(Catalog); | 118 DISALLOW_COPY_AND_ASSIGN(Catalog); |
| 106 }; | 119 }; |
| 107 | 120 |
| 108 } // namespace catalog | 121 } // namespace catalog |
| 109 | 122 |
| 110 #endif // MOJO_SERVICES_CATALOG_CATALOG_H_ | 123 #endif // MOJO_SERVICES_CATALOG_CATALOG_H_ |
| OLD | NEW |