OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/web_socket_proxy_controller.h" | 5 #include "chrome/browser/chromeos/web_socket_proxy_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include <netinet/in.h> | 9 #include <netinet/in.h> |
10 #include <sys/wait.h> | 10 #include <sys/wait.h> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 server_ = NULL; | 94 server_ = NULL; |
95 if (!shutdown_requested_) { | 95 if (!shutdown_requested_) { |
96 // Proxy terminated unexpectedly or failed to start (it can happen due | 96 // Proxy terminated unexpectedly or failed to start (it can happen due |
97 // to a network problem). Keep trying. | 97 // to a network problem). Keep trying. |
98 if (delay_ms_ < 100 * 1000) | 98 if (delay_ms_ < 100 * 1000) |
99 (delay_ms_ *= 3) /= 2; | 99 (delay_ms_ *= 3) /= 2; |
100 | 100 |
101 MessageLoop::current()->PostDelayedTask( | 101 MessageLoop::current()->PostDelayedTask( |
102 FROM_HERE, | 102 FROM_HERE, |
103 base::Bind(&ProxyLifetime::ProxyCallback, base::Unretained(this)), | 103 base::Bind(&ProxyLifetime::ProxyCallback, base::Unretained(this)), |
104 delay_ms_); | 104 base::TimeDelta::FromMilliseconds(delay_ms_)); |
105 } | 105 } |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 // Delay between next attempt to run proxy. | 109 // Delay in milliseconds between next attempt to run proxy. |
110 int volatile delay_ms_; | 110 int volatile delay_ms_; |
111 | 111 |
112 // Proxy listens for incoming websocket connections on this port. | 112 // Proxy listens for incoming websocket connections on this port. |
113 int volatile port_; | 113 int volatile port_; |
114 | 114 |
115 chromeos::WebSocketProxy* volatile server_; | 115 chromeos::WebSocketProxy* volatile server_; |
116 volatile bool shutdown_requested_; | 116 volatile bool shutdown_requested_; |
117 base::Lock lock_; | 117 base::Lock lock_; |
118 content::NotificationRegistrar registrar_; | 118 content::NotificationRegistrar registrar_; |
119 friend class chromeos::WebSocketProxyController; | 119 friend class chromeos::WebSocketProxyController; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 { | 152 { |
153 base::AutoLock alk(g_proxy_lifetime.Get().lock_); | 153 base::AutoLock alk(g_proxy_lifetime.Get().lock_); |
154 g_proxy_lifetime.Get().shutdown_requested_ = true; | 154 g_proxy_lifetime.Get().shutdown_requested_ = true; |
155 if (g_proxy_lifetime.Get().server_) | 155 if (g_proxy_lifetime.Get().server_) |
156 g_proxy_lifetime.Get().server_->Shutdown(); | 156 g_proxy_lifetime.Get().server_->Shutdown(); |
157 } | 157 } |
158 g_proxy_lifetime.Get().web_socket_proxy_thread_.Stop(); | 158 g_proxy_lifetime.Get().web_socket_proxy_thread_.Stop(); |
159 } | 159 } |
160 | 160 |
161 } // namespace chromeos | 161 } // namespace chromeos |
OLD | NEW |