sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 1 | // Copyright 2015 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 COMPONENTS_RESOURCE_PROVIDER_RESOURCE_PROVIDER_APP_H_ |
| 6 | #define COMPONENTS_RESOURCE_PROVIDER_RESOURCE_PROVIDER_APP_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | |
avi | f57136c1 | 2015-12-25 23:27:45 | [diff] [blame] | 10 | #include "base/macros.h" |
sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 11 | #include "components/resource_provider/public/interfaces/resource_provider.mojom.h" |
rockot | 85dce086 | 2015-11-13 01:33:59 | [diff] [blame] | 12 | #include "mojo/public/cpp/bindings/binding.h" |
yzshen | d414dc34 | 2016-02-25 07:29:27 | [diff] [blame] | 13 | #include "mojo/public/cpp/bindings/binding_set.h" |
ben | f709a309 | 2016-04-12 22:38:22 | [diff] [blame] | 14 | #include "services/shell/public/cpp/interface_factory.h" |
| 15 | #include "services/shell/public/cpp/shell_client.h" |
ben | 7095d1a | 2016-04-13 06:14:58 | [diff] [blame^] | 16 | #include "services/tracing/public/cpp/tracing_impl.h" |
sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 17 | |
sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 18 | namespace resource_provider { |
| 19 | |
ben | dbcf6eb | 2016-02-07 15:50:04 | [diff] [blame] | 20 | class ResourceProviderApp : public mojo::ShellClient, |
sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 21 | public mojo::InterfaceFactory<ResourceProvider> { |
| 22 | public: |
jam | 7d1f8ac | 2015-07-16 21:48:22 | [diff] [blame] | 23 | explicit ResourceProviderApp(const std::string& resource_provider_app_url); |
sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 24 | ~ResourceProviderApp() override; |
| 25 | |
| 26 | private: |
ben | dbcf6eb | 2016-02-07 15:50:04 | [diff] [blame] | 27 | // mojo::ShellClient: |
ben | 9a8e15f6 | 2016-03-08 05:17:48 | [diff] [blame] | 28 | void Initialize(mojo::Connector* connector, const mojo::Identity& identity, |
| 29 | uint32_t id) override; |
ben | dbcf6eb | 2016-02-07 15:50:04 | [diff] [blame] | 30 | bool AcceptConnection(mojo::Connection* connection) override; |
sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 31 | |
| 32 | // mojo::InterfaceFactory<ResourceProvider>: |
ben | dbcf6eb | 2016-02-07 15:50:04 | [diff] [blame] | 33 | void Create(mojo::Connection* connection, |
sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 34 | mojo::InterfaceRequest<ResourceProvider> request) override; |
| 35 | |
erg | 8d23e41 | 2015-11-18 22:46:57 | [diff] [blame] | 36 | mojo::TracingImpl tracing_; |
| 37 | |
yzshen | d414dc34 | 2016-02-25 07:29:27 | [diff] [blame] | 38 | mojo::BindingSet<ResourceProvider> bindings_; |
sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 39 | |
jam | 7d1f8ac | 2015-07-16 21:48:22 | [diff] [blame] | 40 | // The name of the app that the resource provider code lives in. When using |
| 41 | // core services, it'll be the url of that. Otherwise it'll just be |
| 42 | // mojo:resource_provider. |
| 43 | std::string resource_provider_app_url_; |
| 44 | |
sky | 63795ba | 2015-05-02 16:29:03 | [diff] [blame] | 45 | DISALLOW_COPY_AND_ASSIGN(ResourceProviderApp); |
| 46 | }; |
| 47 | |
| 48 | } // namespace resource_provider |
| 49 | |
| 50 | #endif // COMPONENTS_RESOURCE_PROVIDER_RESOURCE_PROVIDER_APP_H_ |