Add a string for translation.
[chromium-blink-merge.git] / mojo / shell / dynamic_service_loader.h
blob456295b9153e9c1204c4004915a5232c0b3fecd8
1 // Copyright 2014 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.
5 #ifndef MOJO_SHELL_DYNAMIC_SERVICE_LOADER_H_
6 #define MOJO_SHELL_DYNAMIC_SERVICE_LOADER_H_
8 #include <map>
10 #include "base/macros.h"
11 #include "mojo/public/cpp/system/core.h"
12 #include "mojo/public/interfaces/shell/shell.mojom.h"
13 #include "mojo/service_manager/service_loader.h"
14 #include "mojo/shell/dynamic_service_runner.h"
15 #include "mojo/shell/keep_alive.h"
16 #include "url/gurl.h"
18 namespace mojo {
19 namespace shell {
21 class Context;
22 class DynamicServiceRunnerFactory;
24 // An implementation of ServiceLoader that retrieves a dynamic library
25 // containing the implementation of the service and loads/runs it (via a
26 // DynamicServiceRunner).
27 class DynamicServiceLoader : public ServiceLoader {
28 public:
29 DynamicServiceLoader(Context* context,
30 scoped_ptr<DynamicServiceRunnerFactory> runner_factory);
31 virtual ~DynamicServiceLoader();
33 // Initiates the dynamic load. If the URL has a mojo: scheme, then the name
34 // specified will be modified to the platform's naming scheme. Also, the
35 // value specified to the --origin command line argument will be used as the
36 // host/port.
37 virtual void LoadService(ServiceManager* manager,
38 const GURL& url,
39 ScopedShellHandle service_handle) OVERRIDE;
40 virtual void OnServiceError(ServiceManager* manager, const GURL& url)
41 OVERRIDE;
43 private:
44 class LoadContext;
46 void AppCompleted(const GURL& url);
48 Context* const context_;
49 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_;
51 typedef std::map<GURL, LoadContext*> LoadContextMap;
52 LoadContextMap url_to_load_context_;
54 DISALLOW_COPY_AND_ASSIGN(DynamicServiceLoader);
57 } // namespace shell
58 } // namespace mojo
60 #endif // MOJO_SHELL_DYNAMIC_SERVICE_LOADER_H_