OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 5 #ifndef SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
6 #define SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 6 #define SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <iosfwd> | 10 #include <iosfwd> |
9 #include <string> | 11 #include <string> |
10 | 12 |
11 #include "base/atomicops.h" | 13 #include "base/atomicops.h" |
| 14 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
13 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
14 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
15 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
16 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
17 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
18 #include "sync/base/sync_export.h" | 21 #include "sync/base/sync_export.h" |
19 #include "sync/internal_api/public/base/cancelation_observer.h" | 22 #include "sync/internal_api/public/base/cancelation_observer.h" |
20 #include "sync/syncable/syncable_id.h" | 23 #include "sync/syncable/syncable_id.h" |
21 | 24 |
22 namespace sync_pb { | 25 namespace sync_pb { |
23 class ClientToServerMessage; | 26 class ClientToServerMessage; |
24 } | 27 } |
25 | 28 |
26 namespace syncer { | 29 namespace syncer { |
27 | 30 |
28 class CancelationSignal; | 31 class CancelationSignal; |
29 | 32 |
30 namespace syncable { | 33 namespace syncable { |
31 class Directory; | 34 class Directory; |
32 } | 35 } |
33 | 36 |
34 static const int32 kUnsetResponseCode = -1; | 37 static const int32_t kUnsetResponseCode = -1; |
35 static const int32 kUnsetContentLength = -1; | 38 static const int32_t kUnsetContentLength = -1; |
36 static const int32 kUnsetPayloadLength = -1; | 39 static const int32_t kUnsetPayloadLength = -1; |
37 | 40 |
38 // HttpResponse gathers the relevant output properties of an HTTP request. | 41 // HttpResponse gathers the relevant output properties of an HTTP request. |
39 // Depending on the value of the server_status code, response_code, and | 42 // Depending on the value of the server_status code, response_code, and |
40 // content_length may not be valid. | 43 // content_length may not be valid. |
41 struct SYNC_EXPORT HttpResponse { | 44 struct SYNC_EXPORT HttpResponse { |
42 enum ServerConnectionCode { | 45 enum ServerConnectionCode { |
43 // For uninitialized state. | 46 // For uninitialized state. |
44 NONE, | 47 NONE, |
45 | 48 |
46 // CONNECTION_UNAVAILABLE is returned when InternetConnect() fails. | 49 // CONNECTION_UNAVAILABLE is returned when InternetConnect() fails. |
(...skipping 19 matching lines...) Expand all Loading... |
66 | 69 |
67 // RETRY is returned when a Commit request fails with a RETRY response from | 70 // RETRY is returned when a Commit request fails with a RETRY response from |
68 // the server. | 71 // the server. |
69 // | 72 // |
70 // TODO(idana): the server no longer returns RETRY so we should remove this | 73 // TODO(idana): the server no longer returns RETRY so we should remove this |
71 // value. | 74 // value. |
72 RETRY, | 75 RETRY, |
73 }; | 76 }; |
74 | 77 |
75 // The HTTP Status code. | 78 // The HTTP Status code. |
76 int64 response_code; | 79 int64_t response_code; |
77 | 80 |
78 // The value of the Content-length header. | 81 // The value of the Content-length header. |
79 int64 content_length; | 82 int64_t content_length; |
80 | 83 |
81 // The size of a download request's payload. | 84 // The size of a download request's payload. |
82 int64 payload_length; | 85 int64_t payload_length; |
83 | 86 |
84 // Identifies the type of failure, if any. | 87 // Identifies the type of failure, if any. |
85 ServerConnectionCode server_status; | 88 ServerConnectionCode server_status; |
86 | 89 |
87 HttpResponse(); | 90 HttpResponse(); |
88 | 91 |
89 static const char* GetServerConnectionCodeString( | 92 static const char* GetServerConnectionCodeString( |
90 ServerConnectionCode code); | 93 ServerConnectionCode code); |
91 | 94 |
92 static ServerConnectionCode ServerConnectionCodeFromNetError( | 95 static ServerConnectionCode ServerConnectionCodeFromNetError( |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 bool signal_handler_registered_; | 316 bool signal_handler_registered_; |
314 | 317 |
315 DISALLOW_COPY_AND_ASSIGN(ServerConnectionManager); | 318 DISALLOW_COPY_AND_ASSIGN(ServerConnectionManager); |
316 }; | 319 }; |
317 | 320 |
318 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); | 321 std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); |
319 | 322 |
320 } // namespace syncer | 323 } // namespace syncer |
321 | 324 |
322 #endif // SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ | 325 #endif // SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ |
OLD | NEW |