OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ |
6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ |
7 | 7 |
8 #include "google_apis/gcm/engine/connection_factory.h" | 8 #include "google_apis/gcm/engine/connection_factory.h" |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "google_apis/gcm/protocol/mcs.pb.h" | 12 #include "google_apis/gcm/protocol/mcs.pb.h" |
13 #include "net/base/backoff_entry.h" | 13 #include "net/base/backoff_entry.h" |
14 #include "net/base/network_change_notifier.h" | 14 #include "net/base/network_change_notifier.h" |
15 #include "net/proxy/proxy_info.h" | 15 #include "net/proxy/proxy_info.h" |
16 #include "net/proxy/proxy_service.h" | 16 #include "net/proxy/proxy_service.h" |
17 #include "net/socket/client_socket_handle.h" | 17 #include "net/socket/client_socket_handle.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 class HttpNetworkSession; | 21 class HttpNetworkSession; |
22 class NetLog; | 22 class NetLog; |
23 } | 23 } |
24 | 24 |
25 namespace gcm { | 25 namespace gcm { |
26 | 26 |
27 class ConnectionHandlerImpl; | 27 class ConnectionHandlerImpl; |
| 28 class GCMStatsRecorder; |
28 | 29 |
29 class GCM_EXPORT ConnectionFactoryImpl : | 30 class GCM_EXPORT ConnectionFactoryImpl : |
30 public ConnectionFactory, | 31 public ConnectionFactory, |
31 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 32 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
32 public net::NetworkChangeNotifier::IPAddressObserver { | 33 public net::NetworkChangeNotifier::IPAddressObserver { |
33 public: | 34 public: |
34 ConnectionFactoryImpl( | 35 ConnectionFactoryImpl( |
35 const std::vector<GURL>& mcs_endpoints, | 36 const std::vector<GURL>& mcs_endpoints, |
36 const net::BackoffEntry::Policy& backoff_policy, | 37 const net::BackoffEntry::Policy& backoff_policy, |
37 scoped_refptr<net::HttpNetworkSession> network_session, | 38 scoped_refptr<net::HttpNetworkSession> network_session, |
38 net::NetLog* net_log); | 39 net::NetLog* net_log, |
| 40 GCMStatsRecorder* recorder); |
39 virtual ~ConnectionFactoryImpl(); | 41 virtual ~ConnectionFactoryImpl(); |
40 | 42 |
41 // ConnectionFactory implementation. | 43 // ConnectionFactory implementation. |
42 virtual void Initialize( | 44 virtual void Initialize( |
43 const BuildLoginRequestCallback& request_builder, | 45 const BuildLoginRequestCallback& request_builder, |
44 const ConnectionHandler::ProtoReceivedCallback& read_callback, | 46 const ConnectionHandler::ProtoReceivedCallback& read_callback, |
45 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE; | 47 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE; |
46 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE; | 48 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE; |
47 virtual void Connect() OVERRIDE; | 49 virtual void Connect() OVERRIDE; |
48 virtual bool IsEndpointReachable() const OVERRIDE; | 50 virtual bool IsEndpointReachable() const OVERRIDE; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // The time of the last login completion. Used for calculating whether to | 151 // The time of the last login completion. Used for calculating whether to |
150 // restore a previous backoff entry and for measuring uptime. | 152 // restore a previous backoff entry and for measuring uptime. |
151 base::TimeTicks last_login_time_; | 153 base::TimeTicks last_login_time_; |
152 | 154 |
153 // The current connection handler, if one exists. | 155 // The current connection handler, if one exists. |
154 scoped_ptr<ConnectionHandler> connection_handler_; | 156 scoped_ptr<ConnectionHandler> connection_handler_; |
155 | 157 |
156 // Builder for generating new login requests. | 158 // Builder for generating new login requests. |
157 BuildLoginRequestCallback request_builder_; | 159 BuildLoginRequestCallback request_builder_; |
158 | 160 |
| 161 // Recorder that records GCM activities for debugging purpose. Not owned. |
| 162 GCMStatsRecorder* recorder_; |
| 163 |
159 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; | 164 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; |
160 | 165 |
161 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); | 166 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); |
162 }; | 167 }; |
163 | 168 |
164 } // namespace gcm | 169 } // namespace gcm |
165 | 170 |
166 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ | 171 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ |
OLD | NEW |