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 "chrome/browser/services/gcm/gcm_client_mock.h" | 5 #include "chrome/browser/services/gcm/gcm_client_mock.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "google_apis/gcm/gcm_client.h" | |
jianli
2014/03/04 23:47:39
nit: not needed since it has already been included
juyik
2014/03/05 05:08:08
Done.
| |
13 | 14 |
14 namespace gcm { | 15 namespace gcm { |
15 | 16 |
16 GCMClientMock::GCMClientMock(LoadingDelay loading_delay, | 17 GCMClientMock::GCMClientMock(LoadingDelay loading_delay, |
17 ErrorSimulation error_simulation) | 18 ErrorSimulation error_simulation) |
18 : delegate_(NULL), | 19 : delegate_(NULL), |
19 status_(UNINITIALIZED), | 20 status_(UNINITIALIZED), |
20 loading_delay_(loading_delay), | 21 loading_delay_(loading_delay), |
21 error_simulation_(error_simulation), | 22 error_simulation_(error_simulation), |
22 weak_ptr_factory_(this) { | 23 weak_ptr_factory_(this) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 85 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
85 | 86 |
86 base::MessageLoop::current()->PostTask( | 87 base::MessageLoop::current()->PostTask( |
87 FROM_HERE, | 88 FROM_HERE, |
88 base::Bind(&GCMClientMock::SendFinished, | 89 base::Bind(&GCMClientMock::SendFinished, |
89 weak_ptr_factory_.GetWeakPtr(), | 90 weak_ptr_factory_.GetWeakPtr(), |
90 app_id, | 91 app_id, |
91 message.id)); | 92 message.id)); |
92 } | 93 } |
93 | 94 |
95 GCMClient::GCMStatistics GCMClientMock::GetStatistics() const { | |
96 return stats_; | |
jianli
2014/03/04 23:47:39
Where is it being set? If we intent to return a du
juyik
2014/03/05 05:08:08
Done.
| |
97 } | |
98 | |
94 void GCMClientMock::PerformDelayedLoading() { | 99 void GCMClientMock::PerformDelayedLoading() { |
95 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 100 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
96 | 101 |
97 content::BrowserThread::PostTask( | 102 content::BrowserThread::PostTask( |
98 content::BrowserThread::IO, | 103 content::BrowserThread::IO, |
99 FROM_HERE, | 104 FROM_HERE, |
100 base::Bind(&GCMClientMock::DoLoading, weak_ptr_factory_.GetWeakPtr())); | 105 base::Bind(&GCMClientMock::DoLoading, weak_ptr_factory_.GetWeakPtr())); |
101 } | 106 } |
102 | 107 |
103 void GCMClientMock::ReceiveMessage(const std::string& app_id, | 108 void GCMClientMock::ReceiveMessage(const std::string& app_id, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 delegate_->OnMessagesDeleted(app_id); | 188 delegate_->OnMessagesDeleted(app_id); |
184 } | 189 } |
185 | 190 |
186 void GCMClientMock::MessageSendError(const std::string& app_id, | 191 void GCMClientMock::MessageSendError(const std::string& app_id, |
187 const std::string& message_id) { | 192 const std::string& message_id) { |
188 if (delegate_) | 193 if (delegate_) |
189 delegate_->OnMessageSendError(app_id, message_id, NETWORK_ERROR); | 194 delegate_->OnMessageSendError(app_id, message_id, NETWORK_ERROR); |
190 } | 195 } |
191 | 196 |
192 } // namespace gcm | 197 } // namespace gcm |
OLD | NEW |