summaryrefslogtreecommitdiffstats
path: root/mojo/shell/background/background_shell.h
diff options
context:
space:
mode:
authorsky <sky@chromium.org>2016-02-08 11:48:05 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-08 19:50:42 +0000
commit468d726832348bc0c6415fb8604ccc4e43c84664 (patch)
treef19e18a1ed464867225afc856f248b7d5892bc6c /mojo/shell/background/background_shell.h
parent254a34e2ad1a277e943db2bc129333c2010e4eac (diff)
downloadchromium_src-468d726832348bc0c6415fb8604ccc4e43c84664.zip
chromium_src-468d726832348bc0c6415fb8604ccc4e43c84664.tar.gz
chromium_src-468d726832348bc0c6415fb8604ccc4e43c84664.tar.bz2
Creates BackgroundShell and uses it in test
BackgroundShell creates the necessary mojo state in a background thread and then vends an ApplicationImpl to the main thread so that the main thread can use mojo. I also converted views_apptests to a unittest that makes use of BackgroundShell. BUG=577242, 577274 TEST=none R=ben@chromium.org Review URL: https://codereview.chromium.org/1667273002 Cr-Commit-Position: refs/heads/master@{#374156}
Diffstat (limited to 'mojo/shell/background/background_shell.h')
-rw-r--r--mojo/shell/background/background_shell.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/mojo/shell/background/background_shell.h b/mojo/shell/background/background_shell.h
new file mode 100644
index 0000000..ce68649
--- /dev/null
+++ b/mojo/shell/background/background_shell.h
@@ -0,0 +1,43 @@
+// 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 MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_
+#define MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/shell/public/interfaces/application.mojom.h"
+
+class GURL;
+
+namespace mojo {
+namespace shell {
+
+// BackgroundShell starts up the mojo shell on a background thread, and
+// destroys the thread in the destructor. Once created use CreateApplication()
+// to obtain an InterfaceRequest for the Application. The InterfaceRequest can
+// then be bound to an ApplicationImpl.
+class BackgroundShell {
+ public:
+ BackgroundShell();
+ ~BackgroundShell();
+
+ void Init();
+
+ // Obtains an InterfaceRequest for the specified url.
+ InterfaceRequest<mojom::Application> CreateApplication(const GURL& url);
+
+ private:
+ class MojoThread;
+
+ scoped_ptr<MojoThread> thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackgroundShell);
+};
+
+} // namespace shell
+} // namespace mojo
+
+#endif // MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_