Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: content/common/mojo/existing_thread_loader.h

Issue 1856313002: mojo: Add ExistingThreadLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/mojo/existing_thread_loader.h
diff --git a/content/common/mojo/existing_thread_loader.h b/content/common/mojo/existing_thread_loader.h
new file mode 100644
index 0000000000000000000000000000000000000000..bf54a930a61e0925f3c214196a10a2ad252eab4b
--- /dev/null
+++ b/content/common/mojo/existing_thread_loader.h
@@ -0,0 +1,61 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_MOJO_EXISTING_THREAD_LOADER_H_
+#define CONTENT_COMMON_MOJO_EXISTING_THREAD_LOADER_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "mojo/shell/loader.h"
+#include "mojo/shell/public/cpp/shell_client.h"
+#include "mojo/shell/public/cpp/shell_connection.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+}
+
+namespace content {
+
+// A Loader which loads a single type of app from a mojo::ShellClientFactory on
+// an existing thread.
+class ExistingThreadLoader : public mojo::shell::Loader {
+ public:
+ using ApplicationFactory = base::Callback<scoped_ptr<mojo::ShellClient>()>;
+
+ ExistingThreadLoader(const ApplicationFactory& factory,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+ ~ExistingThreadLoader() override;
+
+ // mojo::shell::Loader:
+ void Load(const std::string& name,
+ mojo::shell::mojom::ShellClientRequest request) override;
+
+ private:
+ void LoadOnTaskRunner(const std::string& name,
+ mojo::shell::mojom::ShellClientRequest request);
+
+ // The factory used to create new instances of the shell client. This is
+ // called exactly once since all connections share a single client.
+ ApplicationFactory factory_;
+
+ // TaskRunner where the |shell_client_| is running on.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
+ // Our shared shell client, passed to each connection.
+ scoped_ptr<mojo::ShellClient> shell_client_;
+
+ std::vector<scoped_ptr<mojo::ShellConnection>> connections_;
+
+ base::WeakPtrFactory<ExistingThreadLoader> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExistingThreadLoader);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_MOJO_EXISTING_THREAD_LOADER_H_
« no previous file with comments | « no previous file | content/common/mojo/existing_thread_loader.cc » ('j') | content/common/mojo/existing_thread_loader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698