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

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

Issue 1780973004: Kill ShellConnection::WaitForInitialize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fuse-api
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
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/public/cpp/bindings/interface_request.h"
9 #include "mojo/shell/public/cpp/capabilities.h" 10 #include "mojo/shell/public/cpp/capabilities.h"
10 #include "mojo/shell/public/cpp/connector.h" 11 #include "mojo/shell/public/cpp/connector.h"
11 #include "mojo/shell/public/cpp/lib/connection_impl.h" 12 #include "mojo/shell/public/cpp/lib/connection_impl.h"
12 #include "mojo/shell/public/cpp/lib/connector_impl.h" 13 #include "mojo/shell/public/cpp/lib/connector_impl.h"
13 #include "mojo/shell/public/cpp/shell_client.h" 14 #include "mojo/shell/public/cpp/shell_client.h"
14 #include "mojo/shell/public/cpp/shell_connection.h" 15 #include "mojo/shell/public/cpp/shell_connection.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 18
18 //////////////////////////////////////////////////////////////////////////////// 19 ////////////////////////////////////////////////////////////////////////////////
19 // ShellConnection, public: 20 // ShellConnection, public:
20 21
21 ShellConnection::ShellConnection( 22 ShellConnection::ShellConnection(
22 mojo::ShellClient* client, 23 mojo::ShellClient* client,
23 InterfaceRequest<shell::mojom::ShellClient> request) 24 InterfaceRequest<shell::mojom::ShellClient> request)
24 : client_(client), 25 : client_(client),
25 binding_(this, std::move(request)), 26 binding_(this, std::move(request)),
26 weak_factory_(this) {} 27 weak_factory_(this) {
28 shell::mojom::ConnectorPtr connector;
29 pending_connector_request_ = GetProxy(&connector);
30 connector_.reset(new ConnectorImpl(std::move(connector)));
31 }
27 32
28 ShellConnection::~ShellConnection() {} 33 ShellConnection::~ShellConnection() {}
29 34
30 void ShellConnection::WaitForInitialize() {
31 DCHECK(!connector_);
32 binding_.WaitForIncomingMethodCall();
33 }
34
35 //////////////////////////////////////////////////////////////////////////////// 35 ////////////////////////////////////////////////////////////////////////////////
36 // ShellConnection, shell::mojom::ShellClient implementation: 36 // ShellConnection, shell::mojom::ShellClient implementation:
37 37
38 void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector, 38 void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector,
39 shell::mojom::IdentityPtr identity, 39 shell::mojom::IdentityPtr identity,
40 uint32_t id) { 40 uint32_t id) {
41 connector_.reset(new ConnectorImpl(std::move(connector))); 41 CHECK(pending_connector_request_.is_pending());
42 CHECK(FuseInterface(std::move(pending_connector_request_),
43 connector.PassInterface()));
44
42 binding_.set_connection_error_handler( 45 binding_.set_connection_error_handler(
43 base::Bind(&ShellConnection::OnConnectionError, 46 base::Bind(&ShellConnection::OnConnectionError,
44 weak_factory_.GetWeakPtr())); 47 weak_factory_.GetWeakPtr()));
45 client_->Initialize(connector_.get(), identity.To<Identity>(), id); 48 client_->Initialize(connector_.get(), identity.To<Identity>(), id);
46 } 49 }
47 50
48 void ShellConnection::AcceptConnection( 51 void ShellConnection::AcceptConnection(
49 shell::mojom::IdentityPtr source, 52 shell::mojom::IdentityPtr source,
50 uint32_t source_id, 53 uint32_t source_id,
51 shell::mojom::InterfaceProviderRequest local_interfaces, 54 shell::mojom::InterfaceProviderRequest local_interfaces,
(...skipping 19 matching lines...) Expand all
71 void ShellConnection::OnConnectionError() { 74 void ShellConnection::OnConnectionError() {
72 // Note that the ShellClient doesn't technically have to quit now, it may live 75 // Note that the ShellClient doesn't technically have to quit now, it may live
73 // on to service existing connections. All existing Connectors however are 76 // on to service existing connections. All existing Connectors however are
74 // invalid. 77 // invalid.
75 client_->ShellConnectionLost(); 78 client_->ShellConnectionLost();
76 // We don't reset the connector as clients may have taken a raw pointer to it. 79 // We don't reset the connector as clients may have taken a raw pointer to it.
77 // Connect() will return nullptr if they try to connect to anything. 80 // Connect() will return nullptr if they try to connect to anything.
78 } 81 }
79 82
80 } // namespace mojo 83 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/background/tests/background_shell_unittest.cc ('k') | mojo/shell/public/cpp/lib/shell_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698