OLD | NEW |
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 "shell/external_application_registrar_connection.h" | 5 #include "shell/external_application_registrar_connection.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return registrar_; | 48 return registrar_; |
49 } | 49 } |
50 DVLOG(1) << "Waiting for connection."; | 50 DVLOG(1) << "Waiting for connection."; |
51 loop.Run(); | 51 loop.Run(); |
52 return registrar_; | 52 return registrar_; |
53 } | 53 } |
54 | 54 |
55 void ExternalApplicationRegistrarConnection::Register( | 55 void ExternalApplicationRegistrarConnection::Register( |
56 const GURL& app_url, | 56 const GURL& app_url, |
57 const std::vector<std::string>& args, | 57 const std::vector<std::string>& args, |
58 base::Callback<void(ShellPtr)> register_complete_callback) { | 58 const RegisterCallback& register_callback) { |
59 DCHECK(!client_socket_); | 59 DCHECK(!client_socket_); |
60 registrar_->Register(String::From(app_url), Array<String>::From(args), | 60 registrar_->Register(String::From(app_url), Array<String>::From(args), |
61 register_complete_callback); | 61 register_callback); |
62 } | 62 } |
63 | 63 |
64 void ExternalApplicationRegistrarConnection::OnConnect(const base::Closure& cb, | 64 void ExternalApplicationRegistrarConnection::OnConnect(const base::Closure& cb, |
65 int rv) { | 65 int rv) { |
66 if (rv != net::OK) { | 66 if (rv != net::OK) { |
67 LOG(ERROR) << "OnConnect called with error: " << net::ErrorToString(rv); | 67 LOG(ERROR) << "OnConnect called with error: " << net::ErrorToString(rv); |
68 cb.Run(); | 68 cb.Run(); |
69 return; | 69 return; |
70 } | 70 } |
71 | 71 |
72 mojo::ScopedMessagePipeHandle ptr_message_pipe_handle = | 72 mojo::ScopedMessagePipeHandle ptr_message_pipe_handle = |
73 channel_init_.Init(client_socket_->ReleaseConnectedSocket(), | 73 channel_init_.Init(client_socket_->ReleaseConnectedSocket(), |
74 base::MessageLoopProxy::current()); | 74 base::MessageLoopProxy::current()); |
75 CHECK(ptr_message_pipe_handle.is_valid()); | 75 CHECK(ptr_message_pipe_handle.is_valid()); |
76 client_socket_.reset(); // This is dead now, ensure it can't be reused. | 76 client_socket_.reset(); // This is dead now, ensure it can't be reused. |
77 | 77 |
78 registrar_.Bind(ptr_message_pipe_handle.Pass()); | 78 registrar_.Bind(ptr_message_pipe_handle.Pass()); |
79 cb.Run(); | 79 cb.Run(); |
80 } | 80 } |
81 | 81 |
82 } // namespace shell | 82 } // namespace shell |
83 } // namespace mojo | 83 } // namespace mojo |
OLD | NEW |