OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mash/shell/shell_application_delegate.h" | 5 #include "mash/shell/shell_application_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "mojo/shell/public/cpp/connection.h" | 8 #include "mojo/shell/public/cpp/connection.h" |
9 #include "mojo/shell/public/cpp/shell.h" | 9 #include "mojo/shell/public/cpp/shell.h" |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 DCHECK(connections_.end() != connection); | 110 DCHECK(connections_.end() != connection); |
111 connections_.erase(connection); | 111 connections_.erase(connection); |
112 } | 112 } |
113 | 113 |
114 void ShellApplicationDelegate::StartRestartableService( | 114 void ShellApplicationDelegate::StartRestartableService( |
115 const std::string& url, | 115 const std::string& url, |
116 const base::Closure& restart_callback) { | 116 const base::Closure& restart_callback) { |
117 // TODO(beng): This would be the place to insert logic that counted restarts | 117 // TODO(beng): This would be the place to insert logic that counted restarts |
118 // to avoid infinite crash-restart loops. | 118 // to avoid infinite crash-restart loops. |
119 scoped_ptr<mojo::Connection> connection = shell_->Connect(url); | 119 scoped_ptr<mojo::Connection> connection = shell_->Connect(url); |
120 connection->SetRemoteServiceProviderConnectionErrorHandler(restart_callback); | 120 // Note: |connection| may be null if we've lost our connection to the shell. |
121 connections_[url] = std::move(connection); | 121 if (connection) { |
| 122 connection->SetRemoteServiceProviderConnectionErrorHandler( |
| 123 restart_callback); |
| 124 connections_[url] = std::move(connection); |
| 125 } |
122 } | 126 } |
123 | 127 |
124 } // namespace shell | 128 } // namespace shell |
125 } // namespace main | 129 } // namespace main |
OLD | NEW |