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

Side by Side Diff: content/browser/mojo/browser_shell_connection.h

Issue 1871223003: Use ShellClientFactory interface to load mojo:profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
(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_BROWSER_MOJO_BROWSER_SHELL_CONNECTION_H_
6 #define CONTENT_BROWSER_MOJO_BROWSER_SHELL_CONNECTION_H_
7
8 #include <memory>
9 #include <string>
10 #include <unordered_map>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/single_thread_task_runner.h"
16 #include "base/strings/string_piece.h"
17 #include "content/common/mojo/embedded_application_runner.h"
18 #include "mojo/public/cpp/bindings/binding_set.h"
19 #include "services/shell/public/cpp/connector.h"
20 #include "services/shell/public/cpp/interface_factory.h"
21 #include "services/shell/public/cpp/shell_client.h"
22 #include "services/shell/public/cpp/shell_connection.h"
23 #include "services/shell/public/interfaces/shell_client.mojom.h"
24 #include "services/shell/public/interfaces/shell_client_factory.mojom.h"
25
26 namespace content {
27
28 // A connection from the browser process to the Mojo shell. There may be
29 // multiple connections in a single browser process. Each connection may have
30 // its own identity, e.g., a connection with unique user ID per BrowserContext.
31 class BrowserShellConnection
32 : public mojo::ShellClient,
33 public mojo::InterfaceFactory<mojo::shell::mojom::ShellClientFactory>,
34 public mojo::shell::mojom::ShellClientFactory {
35 public:
36 explicit BrowserShellConnection(
37 mojo::shell::mojom::ShellClientRequest request);
38 ~BrowserShellConnection() override;
39
40 mojo::Connector* GetConnector();
41
42 // Adds an embedded application to this connection's ShellClientFactory.
43 // |callback| will be used to create a new instance of the application on
44 // |task_runner|'s thread if no instance is running when an incoming
45 // connection is made to |name|. If |task_runner| is null, the calling thread
46 // will be used to run the application.
47 void AddEmbeddedApplication(
48 const base::StringPiece& name,
49 const EmbeddedApplicationRunner::FactoryCallback& callback,
50 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
51
52 private:
53 // mojo::ShellClient:
54 bool AcceptConnection(mojo::Connection* connection) override;
55
56 // mojo::InterfaceFactory<mojo::shell::mojom::ShellClientFactory>:
57 void Create(mojo::Connection* connection,
58 mojo::shell::mojom::ShellClientFactoryRequest request) override;
59
60 // mojo::shell::mojom::ShellClientFactory:
61 void CreateShellClient(mojo::shell::mojom::ShellClientRequest request,
62 const mojo::String& name) override;
63
64 std::unique_ptr<mojo::ShellConnection> shell_connection_;
65 mojo::BindingSet<mojo::shell::mojom::ShellClientFactory> factory_bindings_;
66 std::unordered_map<std::string, std::unique_ptr<EmbeddedApplicationRunner>>
67 embedded_apps_;
68
69 DISALLOW_COPY_AND_ASSIGN(BrowserShellConnection);
70 };
71
72 } // namespace content
73
74 #endif // CONTENT_BROWSER_MOJO_BROWSER_SHELL_CONNECTION_H_
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_wrapper.cc ('k') | content/browser/mojo/browser_shell_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698