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_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/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/time/default_clock.h" | 16 #include "base/time/default_clock.h" |
17 #include "google_apis/gcm/base/encryptor.h" | 17 #include "google_apis/gcm/base/encryptor.h" |
18 #include "google_apis/gcm/base/mcs_message.h" | 18 #include "google_apis/gcm/base/mcs_message.h" |
19 #include "google_apis/gcm/base/mcs_util.h" | 19 #include "google_apis/gcm/base/mcs_util.h" |
20 #include "google_apis/gcm/engine/checkin_request.h" | 20 #include "google_apis/gcm/engine/checkin_request.h" |
21 #include "google_apis/gcm/engine/connection_factory_impl.h" | 21 #include "google_apis/gcm/engine/connection_factory_impl.h" |
22 #include "google_apis/gcm/engine/gcm_store_impl.h" | 22 #include "google_apis/gcm/engine/gcm_store_impl.h" |
23 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 23 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
24 #include "google_apis/gcm/protocol/checkin.pb.h" | 24 #include "google_apis/gcm/protocol/checkin.pb.h" |
25 #include "google_apis/gcm/protocol/mcs.pb.h" | 25 #include "google_apis/gcm/protocol/mcs.pb.h" |
26 #include "net/http/http_network_session.h" | 26 #include "net/http/http_network_session.h" |
27 #include "net/http/http_transaction_factory.h" | |
27 #include "net/url_request/url_request_context.h" | 28 #include "net/url_request/url_request_context.h" |
28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
29 | 30 |
30 namespace gcm { | 31 namespace gcm { |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 // Backoff policy. Shared across reconnection logic and checkin/(un)registration | 35 // Backoff policy. Shared across reconnection logic and checkin/(un)registration |
35 // retries. | 36 // retries. |
36 // Note: In order to ensure a minimum of 20 seconds between server errors (for | 37 // Note: In order to ensure a minimum of 20 seconds between server errors (for |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 270 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
270 const scoped_refptr<net::URLRequestContextGetter>& | 271 const scoped_refptr<net::URLRequestContextGetter>& |
271 url_request_context_getter, | 272 url_request_context_getter, |
272 scoped_ptr<Encryptor> encryptor, | 273 scoped_ptr<Encryptor> encryptor, |
273 GCMClient::Delegate* delegate) { | 274 GCMClient::Delegate* delegate) { |
274 DCHECK_EQ(UNINITIALIZED, state_); | 275 DCHECK_EQ(UNINITIALIZED, state_); |
275 DCHECK(url_request_context_getter); | 276 DCHECK(url_request_context_getter); |
276 DCHECK(delegate); | 277 DCHECK(delegate); |
277 | 278 |
278 url_request_context_getter_ = url_request_context_getter; | 279 url_request_context_getter_ = url_request_context_getter; |
279 const net::HttpNetworkSession::Params* network_session_params = | 280 network_session_ = url_request_context_getter_->GetURLRequestContext() |
280 url_request_context_getter_->GetURLRequestContext()-> | 281 ->http_transaction_factory() |
fgorski
2014/07/08 16:51:33
nit: you are moving the arrows from end of line to
| |
281 GetNetworkSessionParams(); | 282 ->GetSession(); |
282 DCHECK(network_session_params); | |
283 network_session_ = new net::HttpNetworkSession(*network_session_params); | |
284 | 283 |
285 chrome_build_info_ = chrome_build_info; | 284 chrome_build_info_ = chrome_build_info; |
286 | 285 |
287 gcm_store_.reset( | 286 gcm_store_.reset( |
288 new GCMStoreImpl(path, blocking_task_runner, encryptor.Pass())); | 287 new GCMStoreImpl(path, blocking_task_runner, encryptor.Pass())); |
289 | 288 |
290 delegate_ = delegate; | 289 delegate_ = delegate; |
291 | 290 |
292 recorder_.SetDelegate(this); | 291 recorder_.SetDelegate(this); |
293 | 292 |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 | 881 |
883 recorder_.RecordIncomingSendError( | 882 recorder_.RecordIncomingSendError( |
884 data_message_stanza.category(), | 883 data_message_stanza.category(), |
885 data_message_stanza.to(), | 884 data_message_stanza.to(), |
886 data_message_stanza.id()); | 885 data_message_stanza.id()); |
887 delegate_->OnMessageSendError(data_message_stanza.category(), | 886 delegate_->OnMessageSendError(data_message_stanza.category(), |
888 send_error_details); | 887 send_error_details); |
889 } | 888 } |
890 | 889 |
891 } // namespace gcm | 890 } // namespace gcm |
OLD | NEW |