OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/gcm_driver/gcm_driver_desktop.h" | 5 #include "components/gcm_driver/gcm_driver_desktop.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1276 | 1276 |
1277 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) { | 1277 void GCMDriverDesktop::OnConnected(const net::IPEndPoint& ip_endpoint) { |
1278 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 1278 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
1279 | 1279 |
1280 connected_ = true; | 1280 connected_ = true; |
1281 | 1281 |
1282 // Drop the event if the service has been stopped. | 1282 // Drop the event if the service has been stopped. |
1283 if (!gcm_started_) | 1283 if (!gcm_started_) |
1284 return; | 1284 return; |
1285 | 1285 |
1286 FOR_EACH_OBSERVER(GCMConnectionObserver, | 1286 for (GCMConnectionObserver& observer : connection_observer_list_) |
1287 connection_observer_list_, | 1287 observer.OnConnected(ip_endpoint); |
1288 OnConnected(ip_endpoint)); | |
1289 } | 1288 } |
1290 | 1289 |
1291 void GCMDriverDesktop::OnDisconnected() { | 1290 void GCMDriverDesktop::OnDisconnected() { |
1292 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 1291 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
1293 | 1292 |
1294 connected_ = false; | 1293 connected_ = false; |
1295 | 1294 |
1296 // Drop the event if the service has been stopped. | 1295 // Drop the event if the service has been stopped. |
1297 if (!gcm_started_) | 1296 if (!gcm_started_) |
1298 return; | 1297 return; |
1299 | 1298 |
1300 FOR_EACH_OBSERVER( | 1299 for (GCMConnectionObserver& observer : connection_observer_list_) |
1301 GCMConnectionObserver, connection_observer_list_, OnDisconnected()); | 1300 observer.OnDisconnected(); |
1302 } | 1301 } |
1303 | 1302 |
1304 void GCMDriverDesktop::GetGCMStatisticsFinished( | 1303 void GCMDriverDesktop::GetGCMStatisticsFinished( |
1305 const GCMClient::GCMStatistics& stats) { | 1304 const GCMClient::GCMStatistics& stats) { |
1306 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); | 1305 DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
1307 | 1306 |
1308 // request_gcm_statistics_callback_ could be null when an activity, i.e. | 1307 // request_gcm_statistics_callback_ could be null when an activity, i.e. |
1309 // network activity, is triggered while gcm-intenals page is not open. | 1308 // network activity, is triggered while gcm-intenals page is not open. |
1310 if (!request_gcm_statistics_callback_.is_null()) | 1309 if (!request_gcm_statistics_callback_.is_null()) |
1311 request_gcm_statistics_callback_.Run(stats); | 1310 request_gcm_statistics_callback_.Run(stats); |
1312 } | 1311 } |
1313 | 1312 |
1314 bool GCMDriverDesktop::TokenTupleComparer::operator()( | 1313 bool GCMDriverDesktop::TokenTupleComparer::operator()( |
1315 const TokenTuple& a, const TokenTuple& b) const { | 1314 const TokenTuple& a, const TokenTuple& b) const { |
1316 if (std::get<0>(a) < std::get<0>(b)) | 1315 if (std::get<0>(a) < std::get<0>(b)) |
1317 return true; | 1316 return true; |
1318 if (std::get<0>(a) > std::get<0>(b)) | 1317 if (std::get<0>(a) > std::get<0>(b)) |
1319 return false; | 1318 return false; |
1320 | 1319 |
1321 if (std::get<1>(a) < std::get<1>(b)) | 1320 if (std::get<1>(a) < std::get<1>(b)) |
1322 return true; | 1321 return true; |
1323 if (std::get<1>(a) > std::get<1>(b)) | 1322 if (std::get<1>(a) > std::get<1>(b)) |
1324 return false; | 1323 return false; |
1325 | 1324 |
1326 return std::get<2>(a) < std::get<2>(b); | 1325 return std::get<2>(a) < std::get<2>(b); |
1327 } | 1326 } |
1328 | 1327 |
1329 } // namespace gcm | 1328 } // namespace gcm |
OLD | NEW |