OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 #include <vector> | 11 #include <vector> |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 server_reachable_(false), | 151 server_reachable_(false), |
152 reset_count_(0), | 152 reset_count_(0), |
153 terminate_all_io_(false) { | 153 terminate_all_io_(false) { |
154 } | 154 } |
155 | 155 |
156 ServerConnectionManager::~ServerConnectionManager() { | 156 ServerConnectionManager::~ServerConnectionManager() { |
157 delete channel_; | 157 delete channel_; |
158 } | 158 } |
159 | 159 |
160 void ServerConnectionManager::NotifyStatusChanged() { | 160 void ServerConnectionManager::NotifyStatusChanged() { |
161 if (CommandLine::ForCurrentProcess()->HasSwitch( | 161 listeners_->Notify(&ServerConnectionEventListener::OnServerConnectionEvent, |
162 switches::kNewSyncerThread)) { | 162 ServerConnectionEvent2(server_status_, server_reachable_)); |
163 listeners_->Notify(&ServerConnectionEventListener::OnServerConnectionEvent, | |
164 ServerConnectionEvent2(server_status_, server_reachable_)); | |
165 } else { | |
166 ServerConnectionEvent event = { ServerConnectionEvent::STATUS_CHANGED, | |
167 server_status_, | |
168 server_reachable_ }; | |
169 channel_->NotifyListeners(event); | |
170 } | |
171 } | 163 } |
172 | 164 |
173 bool ServerConnectionManager::PostBufferWithCachedAuth( | 165 bool ServerConnectionManager::PostBufferWithCachedAuth( |
174 const PostBufferParams* params, ScopedServerStatusWatcher* watcher) { | 166 const PostBufferParams* params, ScopedServerStatusWatcher* watcher) { |
175 string path = | 167 string path = |
176 MakeSyncServerPath(proto_sync_path(), MakeSyncQueryString(client_id_)); | 168 MakeSyncServerPath(proto_sync_path(), MakeSyncQueryString(client_id_)); |
177 return PostBufferToPath(params, path, auth_token(), watcher); | 169 return PostBufferToPath(params, path, auth_token(), watcher); |
178 } | 170 } |
179 | 171 |
180 bool ServerConnectionManager::PostBufferToPath(const PostBufferParams* params, | 172 bool ServerConnectionManager::PostBufferToPath(const PostBufferParams* params, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 360 } |
369 | 361 |
370 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { | 362 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { |
371 s << " Response Code (bogus on error): " << hr.response_code; | 363 s << " Response Code (bogus on error): " << hr.response_code; |
372 s << " Content-Length (bogus on error): " << hr.content_length; | 364 s << " Content-Length (bogus on error): " << hr.content_length; |
373 s << " Server Status: " << hr.server_status; | 365 s << " Server Status: " << hr.server_status; |
374 return s; | 366 return s; |
375 } | 367 } |
376 | 368 |
377 } // namespace browser_sync | 369 } // namespace browser_sync |
OLD | NEW |