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

Side by Side Diff: mojo/shell/external_application_registrar_connection.h

Issue 522443003: Accept inbound connections on unix domain socket (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug407782
Patch Set: Deleted extra curly brace, which was closing a namespace too early Created 6 years, 2 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 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.
4
5 #ifndef MOJO_SHELL_EXTERNAL_APPLICATION_REGISTRAR_CONNECTION_H_
6 #define MOJO_SHELL_EXTERNAL_APPLICATION_REGISTRAR_CONNECTION_H_
7
8 #include "base/callback_forward.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "mojo/common/common_type_converters.h"
12 #include "mojo/embedder/channel_init.h"
13 #include "mojo/public/cpp/bindings/error_handler.h"
14 #include "mojo/public/interfaces/application/application.mojom.h"
15 #include "mojo/public/interfaces/application/shell.mojom.h"
16 #include "mojo/shell/external_application_registrar.mojom.h"
17 #include "net/socket/socket_descriptor.h"
18 #include "net/socket/unix_domain_client_socket_posix.h"
19 #include "url/gurl.h"
20
21 namespace mojo {
22 namespace shell {
23
24 // Externally-running applications can use this class to discover and register
25 // with a running mojo_shell instance.
26 // MUST be run on an IO thread
27 class ExternalApplicationRegistrarConnection : public ErrorHandler {
28 public:
29 // Configures client_socket_ to point at socket_path.
30 explicit ExternalApplicationRegistrarConnection(
31 const base::FilePath& socket_path);
32 virtual ~ExternalApplicationRegistrarConnection();
33
34 // Implementation of ErrorHandler
35 virtual void OnConnectionError() OVERRIDE;
36
37 // Connects client_socket_ and binds it to registrar_.
38 // Status code is passed to callback upon success or failure.
39 // May return either synchronously or asynchronously, depending on the
40 // status of the underlying socket.
41 void Connect(const net::CompletionCallback& callback);
42
43 // Registers this app with the shell at the provided URL.
44 // shell is not ready for use until register_complete_callback fires.
45 // TODO(cmasone): Once the pipe for shell can be placed in a FIFO relationship
46 // with the one underlying registrar_, the callback becomes unneeded.
47 void Register(const GURL& app_url,
48 ShellPtr* shell,
49 base::Closure register_complete_callback);
50
51 private:
52 // Handles the result of Connect(). If it was successful, promotes the socket
53 // to a MessagePipe and binds it to registrar_.
54 // Hands rv to callback regardless.
55 void OnConnect(net::CompletionCallback callback, int rv);
56
57 scoped_ptr<net::UnixDomainClientSocket> client_socket_;
58 mojo::embedder::ChannelInit channel_init_;
59 ExternalApplicationRegistrarPtr registrar_;
60 };
61
62 } // namespace shell
63 } // namespace mojo
64
65 #endif // MOJO_SHELL_EXTERNAL_APPLICATION_REGISTRAR_CONNECTION_H_
OLDNEW
« no previous file with comments | « mojo/shell/external_application_registrar.mojom ('k') | mojo/shell/external_application_registrar_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698