OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sync/engine/net/server_connection_manager.h" | 5 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include <ostream> | 9 #include <ostream> |
10 #include <string> | 10 #include <string> |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 const bool server_is_reachable = IsServerReachable(); | 248 const bool server_is_reachable = IsServerReachable(); |
249 if (server_reachable_ != server_is_reachable) { | 249 if (server_reachable_ != server_is_reachable) { |
250 server_reachable_ = server_is_reachable; | 250 server_reachable_ = server_is_reachable; |
251 NotifyStatusChanged(); | 251 NotifyStatusChanged(); |
252 } | 252 } |
253 return server_is_reachable; | 253 return server_is_reachable; |
254 } | 254 } |
255 | 255 |
256 void ServerConnectionManager::kill() { | 256 void ServerConnectionManager::kill() { |
257 { | 257 { |
258 AutoLock lock(terminate_all_io_mutex_); | 258 base::AutoLock lock(terminate_all_io_mutex_); |
259 terminate_all_io_ = true; | 259 terminate_all_io_ = true; |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 void ServerConnectionManager::ResetConnection() { | 263 void ServerConnectionManager::ResetConnection() { |
264 base::subtle::NoBarrier_AtomicIncrement(&reset_count_, 1); | 264 base::subtle::NoBarrier_AtomicIncrement(&reset_count_, 1); |
265 } | 265 } |
266 | 266 |
267 bool ServerConnectionManager::IncrementErrorCount() { | 267 bool ServerConnectionManager::IncrementErrorCount() { |
268 error_count_mutex_.Acquire(); | 268 error_count_mutex_.Acquire(); |
(...skipping 18 matching lines...) Expand all Loading... |
287 } | 287 } |
288 | 288 |
289 error_count_mutex_.Release(); | 289 error_count_mutex_.Release(); |
290 return true; | 290 return true; |
291 } | 291 } |
292 | 292 |
293 void ServerConnectionManager::SetServerParameters(const string& server_url, | 293 void ServerConnectionManager::SetServerParameters(const string& server_url, |
294 int port, | 294 int port, |
295 bool use_ssl) { | 295 bool use_ssl) { |
296 { | 296 { |
297 AutoLock lock(server_parameters_mutex_); | 297 base::AutoLock lock(server_parameters_mutex_); |
298 sync_server_ = server_url; | 298 sync_server_ = server_url; |
299 sync_server_port_ = port; | 299 sync_server_port_ = port; |
300 use_ssl_ = use_ssl; | 300 use_ssl_ = use_ssl; |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 // Returns the current server parameters in server_url and port. | 304 // Returns the current server parameters in server_url and port. |
305 void ServerConnectionManager::GetServerParameters(string* server_url, | 305 void ServerConnectionManager::GetServerParameters(string* server_url, |
306 int* port, | 306 int* port, |
307 bool* use_ssl) const { | 307 bool* use_ssl) const { |
308 AutoLock lock(server_parameters_mutex_); | 308 base::AutoLock lock(server_parameters_mutex_); |
309 if (server_url != NULL) | 309 if (server_url != NULL) |
310 *server_url = sync_server_; | 310 *server_url = sync_server_; |
311 if (port != NULL) | 311 if (port != NULL) |
312 *port = sync_server_port_; | 312 *port = sync_server_port_; |
313 if (use_ssl != NULL) | 313 if (use_ssl != NULL) |
314 *use_ssl = use_ssl_; | 314 *use_ssl = use_ssl_; |
315 } | 315 } |
316 | 316 |
317 std::string ServerConnectionManager::GetServerHost() const { | 317 std::string ServerConnectionManager::GetServerHost() const { |
318 string server_url; | 318 string server_url; |
(...skipping 30 matching lines...) Expand all Loading... |
349 } | 349 } |
350 | 350 |
351 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { | 351 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { |
352 s << " Response Code (bogus on error): " << hr.response_code; | 352 s << " Response Code (bogus on error): " << hr.response_code; |
353 s << " Content-Length (bogus on error): " << hr.content_length; | 353 s << " Content-Length (bogus on error): " << hr.content_length; |
354 s << " Server Status: " << hr.server_status; | 354 s << " Server Status: " << hr.server_status; |
355 return s; | 355 return s; |
356 } | 356 } |
357 | 357 |
358 } // namespace browser_sync | 358 } // namespace browser_sync |
OLD | NEW |