Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: components/gcm_driver/gcm_client_impl.cc

Issue 641943002: components: Introduce AlarmTimer class and use it for GCM heartbeat (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build error in mcs_probe Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/gcm_driver/DEPS ('k') | components/gcm_driver/gcm_client_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_client_impl.h" 5 #include "components/gcm_driver/gcm_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/time/default_clock.h" 17 #include "base/time/default_clock.h"
18 #include "components/gcm_driver/gcm_backoff_policy.h" 18 #include "components/gcm_driver/gcm_backoff_policy.h"
19 #include "components/timers/alarm_timer.h"
19 #include "google_apis/gcm/base/encryptor.h" 20 #include "google_apis/gcm/base/encryptor.h"
20 #include "google_apis/gcm/base/mcs_message.h" 21 #include "google_apis/gcm/base/mcs_message.h"
21 #include "google_apis/gcm/base/mcs_util.h" 22 #include "google_apis/gcm/base/mcs_util.h"
22 #include "google_apis/gcm/engine/checkin_request.h" 23 #include "google_apis/gcm/engine/checkin_request.h"
23 #include "google_apis/gcm/engine/connection_factory_impl.h" 24 #include "google_apis/gcm/engine/connection_factory_impl.h"
24 #include "google_apis/gcm/engine/gcm_store_impl.h" 25 #include "google_apis/gcm/engine/gcm_store_impl.h"
25 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" 26 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
26 #include "google_apis/gcm/protocol/checkin.pb.h" 27 #include "google_apis/gcm/protocol/checkin.pb.h"
27 #include "google_apis/gcm/protocol/mcs.pb.h" 28 #include "google_apis/gcm/protocol/mcs.pb.h"
28 #include "net/http/http_network_session.h" 29 #include "net/http/http_network_session.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 scoped_ptr<base::Clock> GCMInternalsBuilder::BuildClock() { 186 scoped_ptr<base::Clock> GCMInternalsBuilder::BuildClock() {
186 return make_scoped_ptr<base::Clock>(new base::DefaultClock()); 187 return make_scoped_ptr<base::Clock>(new base::DefaultClock());
187 } 188 }
188 189
189 scoped_ptr<MCSClient> GCMInternalsBuilder::BuildMCSClient( 190 scoped_ptr<MCSClient> GCMInternalsBuilder::BuildMCSClient(
190 const std::string& version, 191 const std::string& version,
191 base::Clock* clock, 192 base::Clock* clock,
192 ConnectionFactory* connection_factory, 193 ConnectionFactory* connection_factory,
193 GCMStore* gcm_store, 194 GCMStore* gcm_store,
194 GCMStatsRecorder* recorder) { 195 GCMStatsRecorder* recorder) {
195 return make_scoped_ptr<MCSClient>( 196 #if defined(OS_CHROMEOS)
196 new MCSClient(version, 197 return scoped_ptr<MCSClient>(new MCSClient(
197 clock, 198 version, clock, connection_factory, gcm_store, recorder,
198 connection_factory, 199 make_scoped_ptr(new timers::AlarmTimer(true, /* retain user task */
199 gcm_store, 200 false /* non-repeating */))));
200 recorder)); 201 #else
202 return scoped_ptr<MCSClient>(new MCSClient(
203 version, clock, connection_factory, gcm_store, recorder,
204 make_scoped_ptr(new base::Timer(true, /* retain user task */
205 false /* non-repeating */))));
206 #endif // defined(OS_CHROMEOS)
201 } 207 }
202 208
203 scoped_ptr<ConnectionFactory> GCMInternalsBuilder::BuildConnectionFactory( 209 scoped_ptr<ConnectionFactory> GCMInternalsBuilder::BuildConnectionFactory(
204 const std::vector<GURL>& endpoints, 210 const std::vector<GURL>& endpoints,
205 const net::BackoffEntry::Policy& backoff_policy, 211 const net::BackoffEntry::Policy& backoff_policy,
206 const scoped_refptr<net::HttpNetworkSession>& gcm_network_session, 212 const scoped_refptr<net::HttpNetworkSession>& gcm_network_session,
207 const scoped_refptr<net::HttpNetworkSession>& http_network_session, 213 const scoped_refptr<net::HttpNetworkSession>& http_network_session,
208 net::NetLog* net_log, 214 net::NetLog* net_log,
209 GCMStatsRecorder* recorder) { 215 GCMStatsRecorder* recorder) {
210 return make_scoped_ptr<ConnectionFactory>( 216 return make_scoped_ptr<ConnectionFactory>(
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 976
971 recorder_.RecordIncomingSendError( 977 recorder_.RecordIncomingSendError(
972 data_message_stanza.category(), 978 data_message_stanza.category(),
973 data_message_stanza.to(), 979 data_message_stanza.to(),
974 data_message_stanza.id()); 980 data_message_stanza.id());
975 delegate_->OnMessageSendError(data_message_stanza.category(), 981 delegate_->OnMessageSendError(data_message_stanza.category(),
976 send_error_details); 982 send_error_details);
977 } 983 }
978 984
979 } // namespace gcm 985 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/DEPS ('k') | components/gcm_driver/gcm_client_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698