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 CONTENT_COMMON_MOJO_CURRENT_THREAD_LOADER_H_ |
| 6 #define CONTENT_COMMON_MOJO_CURRENT_THREAD_LOADER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
| 12 #include "mojo/shell/loader.h" |
| 13 #include "mojo/shell/public/cpp/shell_client.h" |
| 14 #include "mojo/shell/public/cpp/shell_connection.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 // TODO(erg): The loader needs to know when the app dies. |
| 19 |
| 20 // A Loader which loads a single type of app from a mojo::ShellClientFactory on |
| 21 // the current thread. |
| 22 class CurrentThreadLoader : public mojo::shell::Loader { |
| 23 public: |
| 24 using ApplicationFactory = base::Callback<scoped_ptr<mojo::ShellClient>()>; |
| 25 |
| 26 explicit CurrentThreadLoader(const ApplicationFactory& factory); |
| 27 ~CurrentThreadLoader() override; |
| 28 |
| 29 // mojo::shell::Loader: |
| 30 void Load(const std::string& name, |
| 31 mojo::shell::mojom::ShellClientRequest request) override; |
| 32 |
| 33 private: |
| 34 // The factory used to create new instances of the application delegate. This |
| 35 // is called exactly once since all |
| 36 ApplicationFactory factory_; |
| 37 |
| 38 // Our shared shell client, passed to each connection. |
| 39 scoped_ptr<mojo::ShellClient> shell_client_; |
| 40 |
| 41 std::vector<scoped_ptr<mojo::ShellConnection>> connections_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(CurrentThreadLoader); |
| 44 }; |
| 45 |
| 46 } // namespace content |
| 47 |
| 48 #endif // CONTENT_COMMON_MOJO_CURRENT_THREAD_LOADER_H_ |
OLD | NEW |