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 "services/shell/public/cpp/application_runner.h" | 5 #include "services/shell/public/cpp/application_runner.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 { | 50 { |
51 std::unique_ptr<base::MessageLoop> loop; | 51 std::unique_ptr<base::MessageLoop> loop; |
52 loop.reset(new base::MessageLoop(message_loop_type_)); | 52 loop.reset(new base::MessageLoop(message_loop_type_)); |
53 | 53 |
54 connection_.reset(new ShellConnection( | 54 connection_.reset(new ShellConnection( |
55 client_.get(), | 55 client_.get(), |
56 mojo::MakeRequest<mojom::ShellClient>(mojo::MakeScopedHandle( | 56 mojo::MakeRequest<mojom::ShellClient>(mojo::MakeScopedHandle( |
57 mojo::MessagePipeHandle(shell_client_request_handle))))); | 57 mojo::MessagePipeHandle(shell_client_request_handle))))); |
58 base::RunLoop run_loop; | 58 base::RunLoop run_loop; |
59 connection_->set_connection_lost_closure(run_loop.QuitClosure()); | 59 connection_->SetConnectionLostClosure(run_loop.QuitClosure()); |
60 run_loop.Run(); | 60 run_loop.Run(); |
61 // It's very common for the client to cache the app and terminate on errors. | 61 // It's very common for the client to cache the app and terminate on errors. |
62 // If we don't delete the client before the app we run the risk of the | 62 // If we don't delete the client before the app we run the risk of the |
63 // client having a stale reference to the app and trying to use it. | 63 // client having a stale reference to the app and trying to use it. |
64 // Note that we destruct the message loop first because that might trigger | 64 // Note that we destruct the message loop first because that might trigger |
65 // connection error handlers and they might access objects created by the | 65 // connection error handlers and they might access objects created by the |
66 // client. | 66 // client. |
67 loop.reset(); | 67 loop.reset(); |
68 client_.reset(); | 68 client_.reset(); |
69 connection_.reset(); | 69 connection_.reset(); |
(...skipping 12 matching lines...) Expand all Loading... |
82 | 82 |
83 void ApplicationRunner::DestroyShellConnection() { | 83 void ApplicationRunner::DestroyShellConnection() { |
84 connection_.reset(); | 84 connection_.reset(); |
85 } | 85 } |
86 | 86 |
87 void ApplicationRunner::Quit() { | 87 void ApplicationRunner::Quit() { |
88 base::MessageLoop::current()->QuitWhenIdle(); | 88 base::MessageLoop::current()->QuitWhenIdle(); |
89 } | 89 } |
90 | 90 |
91 } // namespace shell | 91 } // namespace shell |
OLD | NEW |