| 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/fake_gcm_client.h" | 5 #include "components/gcm_driver/fake_gcm_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 void FakeGCMClient::Send(const std::string& app_id, | 151 void FakeGCMClient::Send(const std::string& app_id, |
| 152 const std::string& receiver_id, | 152 const std::string& receiver_id, |
| 153 const OutgoingMessage& message) { | 153 const OutgoingMessage& message) { |
| 154 DCHECK(io_thread_->RunsTasksOnCurrentThread()); | 154 DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
| 155 | 155 |
| 156 base::ThreadTaskRunnerHandle::Get()->PostTask( | 156 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 157 FROM_HERE, base::Bind(&FakeGCMClient::SendFinished, | 157 FROM_HERE, base::Bind(&FakeGCMClient::SendFinished, |
| 158 weak_ptr_factory_.GetWeakPtr(), app_id, message)); | 158 weak_ptr_factory_.GetWeakPtr(), app_id, message)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void FakeGCMClient::RecordDecryptionFailure( | |
| 162 const std::string& app_id, | |
| 163 GCMEncryptionProvider::DecryptionFailure reason) { | |
| 164 recorder_.RecordDecryptionFailure(app_id, reason); | |
| 165 } | |
| 166 | |
| 167 void FakeGCMClient::SetRecording(bool recording) { | 161 void FakeGCMClient::SetRecording(bool recording) { |
| 168 recorder_.set_is_recording(recording); | |
| 169 } | 162 } |
| 170 | 163 |
| 171 void FakeGCMClient::ClearActivityLogs() { | 164 void FakeGCMClient::ClearActivityLogs() { |
| 172 recorder_.Clear(); | |
| 173 } | 165 } |
| 174 | 166 |
| 175 GCMClient::GCMStatistics FakeGCMClient::GetStatistics() const { | 167 GCMClient::GCMStatistics FakeGCMClient::GetStatistics() const { |
| 176 GCMClient::GCMStatistics statistics; | 168 return GCMClient::GCMStatistics(); |
| 177 statistics.is_recording = recorder_.is_recording(); | |
| 178 | |
| 179 recorder_.CollectActivities(&statistics.recorded_activities); | |
| 180 return statistics; | |
| 181 } | 169 } |
| 182 | 170 |
| 183 void FakeGCMClient::SetAccountTokens( | 171 void FakeGCMClient::SetAccountTokens( |
| 184 const std::vector<AccountTokenInfo>& account_tokens) { | 172 const std::vector<AccountTokenInfo>& account_tokens) { |
| 185 } | 173 } |
| 186 | 174 |
| 187 void FakeGCMClient::UpdateAccountMapping( | 175 void FakeGCMClient::UpdateAccountMapping( |
| 188 const AccountMapping& account_mapping) { | 176 const AccountMapping& account_mapping) { |
| 189 } | 177 } |
| 190 | 178 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 delegate_->OnMessageSendError(app_id, send_error_details); | 307 delegate_->OnMessageSendError(app_id, send_error_details); |
| 320 } | 308 } |
| 321 | 309 |
| 322 void FakeGCMClient::SendAcknowledgement(const std::string& app_id, | 310 void FakeGCMClient::SendAcknowledgement(const std::string& app_id, |
| 323 const std::string& message_id) { | 311 const std::string& message_id) { |
| 324 if (delegate_) | 312 if (delegate_) |
| 325 delegate_->OnSendAcknowledged(app_id, message_id); | 313 delegate_->OnSendAcknowledged(app_id, message_id); |
| 326 } | 314 } |
| 327 | 315 |
| 328 } // namespace gcm | 316 } // namespace gcm |
| OLD | NEW |