| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "google_apis/gcm/engine/mcs_client.h" | 5 #include "google_apis/gcm/engine/mcs_client.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/time/clock.h" | 14 #include "base/time/clock.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "base/timer/timer.h" |
| 15 #include "google_apis/gcm/base/mcs_util.h" | 17 #include "google_apis/gcm/base/mcs_util.h" |
| 16 #include "google_apis/gcm/base/socket_stream.h" | 18 #include "google_apis/gcm/base/socket_stream.h" |
| 17 #include "google_apis/gcm/engine/connection_factory.h" | 19 #include "google_apis/gcm/engine/connection_factory.h" |
| 18 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 20 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
| 19 | 21 |
| 20 using namespace google::protobuf::io; | 22 using namespace google::protobuf::io; |
| 21 | 23 |
| 22 namespace gcm { | 24 namespace gcm { |
| 23 | 25 |
| 24 namespace { | 26 namespace { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 default: | 152 default: |
| 151 NOTREACHED(); | 153 NOTREACHED(); |
| 152 return std::string(); | 154 return std::string(); |
| 153 } | 155 } |
| 154 } | 156 } |
| 155 | 157 |
| 156 MCSClient::MCSClient(const std::string& version_string, | 158 MCSClient::MCSClient(const std::string& version_string, |
| 157 base::Clock* clock, | 159 base::Clock* clock, |
| 158 ConnectionFactory* connection_factory, | 160 ConnectionFactory* connection_factory, |
| 159 GCMStore* gcm_store, | 161 GCMStore* gcm_store, |
| 160 GCMStatsRecorder* recorder) | 162 GCMStatsRecorder* recorder, |
| 163 scoped_ptr<base::Timer> heartbeat_timer) |
| 161 : version_string_(version_string), | 164 : version_string_(version_string), |
| 162 clock_(clock), | 165 clock_(clock), |
| 163 state_(UNINITIALIZED), | 166 state_(UNINITIALIZED), |
| 164 android_id_(0), | 167 android_id_(0), |
| 165 security_token_(0), | 168 security_token_(0), |
| 166 connection_factory_(connection_factory), | 169 connection_factory_(connection_factory), |
| 167 connection_handler_(NULL), | 170 connection_handler_(NULL), |
| 168 last_device_to_server_stream_id_received_(0), | 171 last_device_to_server_stream_id_received_(0), |
| 169 last_server_to_device_stream_id_received_(0), | 172 last_server_to_device_stream_id_received_(0), |
| 170 stream_id_out_(0), | 173 stream_id_out_(0), |
| 171 stream_id_in_(0), | 174 stream_id_in_(0), |
| 172 gcm_store_(gcm_store), | 175 gcm_store_(gcm_store), |
| 176 heartbeat_manager_(heartbeat_timer.Pass()), |
| 173 recorder_(recorder), | 177 recorder_(recorder), |
| 174 weak_ptr_factory_(this) { | 178 weak_ptr_factory_(this) { |
| 175 } | 179 } |
| 176 | 180 |
| 177 MCSClient::~MCSClient() { | 181 MCSClient::~MCSClient() { |
| 178 } | 182 } |
| 179 | 183 |
| 180 void MCSClient::Initialize( | 184 void MCSClient::Initialize( |
| 181 const ErrorCallback& error_callback, | 185 const ErrorCallback& error_callback, |
| 182 const OnMessageReceivedCallback& message_received_callback, | 186 const OnMessageReceivedCallback& message_received_callback, |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 reinterpret_cast<mcs_proto::DataMessageStanza*>(packet->protobuf.get()); | 901 reinterpret_cast<mcs_proto::DataMessageStanza*>(packet->protobuf.get()); |
| 898 CollapseKey collapse_key(*data_message); | 902 CollapseKey collapse_key(*data_message); |
| 899 if (collapse_key.IsValid()) | 903 if (collapse_key.IsValid()) |
| 900 collapse_key_map_.erase(collapse_key); | 904 collapse_key_map_.erase(collapse_key); |
| 901 } | 905 } |
| 902 | 906 |
| 903 return packet; | 907 return packet; |
| 904 } | 908 } |
| 905 | 909 |
| 906 } // namespace gcm | 910 } // namespace gcm |
| OLD | NEW |