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 "sync/engine/net/server_connection_manager.h" | 5 #include "sync/engine/net/server_connection_manager.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <ostream> | 10 #include <ostream> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 ENUM_CASE(SYNC_AUTH_ERROR); | 48 ENUM_CASE(SYNC_AUTH_ERROR); |
49 ENUM_CASE(SERVER_CONNECTION_OK); | 49 ENUM_CASE(SERVER_CONNECTION_OK); |
50 ENUM_CASE(RETRY); | 50 ENUM_CASE(RETRY); |
51 } | 51 } |
52 NOTREACHED(); | 52 NOTREACHED(); |
53 return ""; | 53 return ""; |
54 } | 54 } |
55 | 55 |
56 #undef ENUM_CASE | 56 #undef ENUM_CASE |
57 | 57 |
58 // TODO(clamy): check if all errors are in the right category. | |
59 HttpResponse::ServerConnectionCode | |
60 HttpResponse::ServerConnectionCodeFromNetError(int error_code) { | |
61 switch (error_code) { | |
62 case net::ERR_ABORTED: | |
63 case net::ERR_SOCKET_NOT_CONNECTED: | |
64 case net::ERR_NETWORK_CHANGED: | |
65 case net::ERR_CONNECTION_FAILED: | |
66 case net::ERR_NAME_NOT_RESOLVED: | |
67 case net::ERR_INTERNET_DISCONNECTED: | |
68 case net::ERR_NETWORK_ACCESS_DENIED: | |
69 case net::ERR_NETWORK_IO_SUSPENDED: | |
70 return CONNECTION_UNAVAILABLE; | |
71 } | |
72 return IO_ERROR; | |
73 } | |
74 | |
75 ServerConnectionManager::Connection::Connection( | 58 ServerConnectionManager::Connection::Connection( |
76 ServerConnectionManager* scm) : scm_(scm) { | 59 ServerConnectionManager* scm) : scm_(scm) { |
77 } | 60 } |
78 | 61 |
79 ServerConnectionManager::Connection::~Connection() { | 62 ServerConnectionManager::Connection::~Connection() { |
80 } | 63 } |
81 | 64 |
82 bool ServerConnectionManager::Connection::ReadBufferResponse( | 65 bool ServerConnectionManager::Connection::ReadBufferResponse( |
83 string* buffer_out, | 66 string* buffer_out, |
84 HttpResponse* response, | 67 HttpResponse* response, |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 355 |
373 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { | 356 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { |
374 s << " Response Code (bogus on error): " << hr.response_code; | 357 s << " Response Code (bogus on error): " << hr.response_code; |
375 s << " Content-Length (bogus on error): " << hr.content_length; | 358 s << " Content-Length (bogus on error): " << hr.content_length; |
376 s << " Server Status: " | 359 s << " Server Status: " |
377 << HttpResponse::GetServerConnectionCodeString(hr.server_status); | 360 << HttpResponse::GetServerConnectionCodeString(hr.server_status); |
378 return s; | 361 return s; |
379 } | 362 } |
380 | 363 |
381 } // namespace syncer | 364 } // namespace syncer |
OLD | NEW |