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

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

Issue 1821913002: Revert of Quit the message loop by default in ShellConnectionLost when ApplicationRunner is used (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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/background/tests/test_service.cc ('k') | mojo/shell/public/cpp/lib/shell_client.cc » ('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 "mojo/shell/public/cpp/application_runner.h" 5 #include "mojo/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"
9 #include "base/command_line.h" 8 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
12 #include "base/process/launch.h" 11 #include "base/process/launch.h"
13 #include "base/run_loop.h"
14 #include "mojo/shell/public/cpp/shell_client.h" 12 #include "mojo/shell/public/cpp/shell_client.h"
15 #include "mojo/shell/public/cpp/shell_connection.h" 13 #include "mojo/shell/public/cpp/shell_connection.h"
16 14
17 namespace mojo { 15 namespace mojo {
18 16
19 int g_application_runner_argc; 17 int g_application_runner_argc;
20 const char* const* g_application_runner_argv; 18 const char* const* g_application_runner_argv;
21 19
22 ApplicationRunner::ApplicationRunner(ShellClient* client) 20 ApplicationRunner::ApplicationRunner(ShellClient* client)
23 : client_(scoped_ptr<ShellClient>(client)), 21 : client_(scoped_ptr<ShellClient>(client)),
(...skipping 25 matching lines...) Expand all
49 } 47 }
50 48
51 { 49 {
52 scoped_ptr<base::MessageLoop> loop; 50 scoped_ptr<base::MessageLoop> loop;
53 loop.reset(new base::MessageLoop(message_loop_type_)); 51 loop.reset(new base::MessageLoop(message_loop_type_));
54 52
55 connection_.reset(new ShellConnection( 53 connection_.reset(new ShellConnection(
56 client_.get(), 54 client_.get(),
57 MakeRequest<shell::mojom::ShellClient>(MakeScopedHandle( 55 MakeRequest<shell::mojom::ShellClient>(MakeScopedHandle(
58 MessagePipeHandle(shell_client_request_handle))))); 56 MessagePipeHandle(shell_client_request_handle)))));
59 base::RunLoop run_loop; 57 loop->Run();
60 connection_->set_connection_lost_closure(run_loop.QuitClosure());
61 run_loop.Run();
62 // It's very common for the client to cache the app and terminate on errors. 58 // It's very common for the client to cache the app and terminate on errors.
63 // If we don't delete the client before the app we run the risk of the 59 // If we don't delete the client before the app we run the risk of the
64 // client having a stale reference to the app and trying to use it. 60 // client having a stale reference to the app and trying to use it.
65 // Note that we destruct the message loop first because that might trigger 61 // Note that we destruct the message loop first because that might trigger
66 // connection error handlers and they might access objects created by the 62 // connection error handlers and they might access objects created by the
67 // client. 63 // client.
68 loop.reset(); 64 loop.reset();
69 client_.reset(); 65 client_.reset();
70 connection_.reset(); 66 connection_.reset();
71 } 67 }
(...skipping 11 matching lines...) Expand all
83 79
84 void ApplicationRunner::DestroyShellConnection() { 80 void ApplicationRunner::DestroyShellConnection() {
85 connection_.reset(); 81 connection_.reset();
86 } 82 }
87 83
88 void ApplicationRunner::Quit() { 84 void ApplicationRunner::Quit() {
89 base::MessageLoop::current()->QuitWhenIdle(); 85 base::MessageLoop::current()->QuitWhenIdle();
90 } 86 }
91 87
92 } // namespace mojo 88 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/background/tests/test_service.cc ('k') | mojo/shell/public/cpp/lib/shell_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698