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

Side by Side Diff: mojo/shell/public/cpp/lib/shell_connection.cc

Issue 1743473002: Change Mojo URLs to structured names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@18collapse
Patch Set: . Created 4 years, 9 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
« no previous file with comments | « mojo/shell/public/cpp/lib/shell_client.cc ('k') | mojo/shell/public/cpp/names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "mojo/public/cpp/bindings/interface_ptr.h" 8 #include "mojo/public/cpp/bindings/interface_ptr.h"
9 #include "mojo/shell/public/cpp/connector.h" 9 #include "mojo/shell/public/cpp/connector.h"
10 #include "mojo/shell/public/cpp/lib/connection_impl.h" 10 #include "mojo/shell/public/cpp/lib/connection_impl.h"
(...skipping 17 matching lines...) Expand all
28 28
29 void ShellConnection::WaitForInitialize() { 29 void ShellConnection::WaitForInitialize() {
30 DCHECK(!connector_); 30 DCHECK(!connector_);
31 binding_.WaitForIncomingMethodCall(); 31 binding_.WaitForIncomingMethodCall();
32 } 32 }
33 33
34 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
35 // ShellConnection, shell::mojom::ShellClient implementation: 35 // ShellConnection, shell::mojom::ShellClient implementation:
36 36
37 void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector, 37 void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector,
38 const mojo::String& url, 38 const mojo::String& name,
39 uint32_t id, 39 uint32_t id,
40 uint32_t user_id) { 40 uint32_t user_id) {
41 connector_.reset(new ConnectorImpl( 41 connector_.reset(new ConnectorImpl(
42 std::move(connector), 42 std::move(connector),
43 base::Bind(&ShellConnection::OnConnectionError, 43 base::Bind(&ShellConnection::OnConnectionError,
44 weak_factory_.GetWeakPtr()))); 44 weak_factory_.GetWeakPtr())));
45 client_->Initialize(connector_.get(), url, id, user_id); 45 client_->Initialize(connector_.get(), name, id, user_id);
46 } 46 }
47 47
48 void ShellConnection::AcceptConnection( 48 void ShellConnection::AcceptConnection(
49 const String& requestor_url, 49 const String& requestor_name,
50 uint32_t requestor_id, 50 uint32_t requestor_id,
51 uint32_t requestor_user_id, 51 uint32_t requestor_user_id,
52 shell::mojom::InterfaceProviderRequest local_interfaces, 52 shell::mojom::InterfaceProviderRequest local_interfaces,
53 shell::mojom::InterfaceProviderPtr remote_interfaces, 53 shell::mojom::InterfaceProviderPtr remote_interfaces,
54 Array<String> allowed_interfaces, 54 Array<String> allowed_interfaces,
55 const String& url) { 55 const String& name) {
56 scoped_ptr<Connection> registry(new internal::ConnectionImpl( 56 scoped_ptr<Connection> registry(new internal::ConnectionImpl(
57 url, requestor_url, requestor_id, requestor_user_id, 57 name, requestor_name, requestor_id, requestor_user_id,
58 std::move(remote_interfaces), std::move(local_interfaces), 58 std::move(remote_interfaces), std::move(local_interfaces),
59 allowed_interfaces.To<std::set<std::string>>())); 59 allowed_interfaces.To<std::set<std::string>>()));
60 if (!client_->AcceptConnection(registry.get())) 60 if (!client_->AcceptConnection(registry.get()))
61 return; 61 return;
62 62
63 // TODO(beng): it appears we never prune this list. We should, when the 63 // TODO(beng): it appears we never prune this list. We should, when the
64 // connection's remote service provider pipe breaks. 64 // connection's remote service provider pipe breaks.
65 incoming_connections_.push_back(std::move(registry)); 65 incoming_connections_.push_back(std::move(registry));
66 } 66 }
67 67
68 //////////////////////////////////////////////////////////////////////////////// 68 ////////////////////////////////////////////////////////////////////////////////
69 // ShellConnection, private: 69 // ShellConnection, private:
70 70
71 void ShellConnection::OnConnectionError() { 71 void ShellConnection::OnConnectionError() {
72 // We give the client notice first, since it might want to do something on 72 // We give the client notice first, since it might want to do something on
73 // shell connection errors other than immediate termination of the run 73 // shell connection errors other than immediate termination of the run
74 // loop. The application might want to continue servicing connections other 74 // loop. The application might want to continue servicing connections other
75 // than the one to the shell. 75 // than the one to the shell.
76 if (client_->ShellConnectionLost()) 76 if (client_->ShellConnectionLost())
77 connector_.reset(); 77 connector_.reset();
78 } 78 }
79 79
80 } // namespace mojo 80 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/lib/shell_client.cc ('k') | mojo/shell/public/cpp/names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698