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 #ifndef GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 5 #ifndef GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
6 #define GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 6 #define GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "google_apis/gcm/base/mcs_message.h" | 16 #include "google_apis/gcm/base/mcs_message.h" |
| 17 #include "google_apis/gcm/engine/gcm_internals_builder.h" |
17 #include "google_apis/gcm/engine/gcm_store.h" | 18 #include "google_apis/gcm/engine/gcm_store.h" |
18 #include "google_apis/gcm/engine/mcs_client.h" | 19 #include "google_apis/gcm/engine/mcs_client.h" |
19 #include "google_apis/gcm/engine/registration_request.h" | 20 #include "google_apis/gcm/engine/registration_request.h" |
20 #include "google_apis/gcm/engine/unregistration_request.h" | 21 #include "google_apis/gcm/engine/unregistration_request.h" |
21 #include "google_apis/gcm/gcm_client.h" | 22 #include "google_apis/gcm/gcm_client.h" |
22 #include "google_apis/gcm/protocol/android_checkin.pb.h" | 23 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
23 #include "net/base/net_log.h" | 24 #include "net/base/net_log.h" |
24 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
25 | 26 |
26 class GURL; | |
27 | |
28 namespace base { | 27 namespace base { |
29 class Clock; | 28 class Clock; |
| 29 class FilePath; |
30 } // namespace base | 30 } // namespace base |
31 | 31 |
32 namespace net { | 32 namespace net { |
33 class HttpNetworkSession; | 33 class HttpNetworkSession; |
34 } // namespace net | 34 } // namespace net |
35 | 35 |
36 namespace gcm { | 36 namespace gcm { |
37 | 37 |
38 class CheckinRequest; | 38 class CheckinRequest; |
39 class ConnectionFactory; | 39 class ConnectionFactory; |
40 class GCMClientImplTest; | 40 class GCMClientImplTest; |
41 | 41 |
42 // Helper class for building GCM internals. Allows tests to inject fake versions | |
43 // as necessary. | |
44 class GCM_EXPORT GCMInternalsBuilder { | |
45 public: | |
46 GCMInternalsBuilder(); | |
47 virtual ~GCMInternalsBuilder(); | |
48 | |
49 virtual scoped_ptr<base::Clock> BuildClock(); | |
50 virtual scoped_ptr<MCSClient> BuildMCSClient( | |
51 const std::string& version, | |
52 base::Clock* clock, | |
53 ConnectionFactory* connection_factory, | |
54 GCMStore* gcm_store); | |
55 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( | |
56 const std::vector<GURL>& endpoints, | |
57 const net::BackoffEntry::Policy& backoff_policy, | |
58 scoped_refptr<net::HttpNetworkSession> network_session, | |
59 net::NetLog* net_log); | |
60 }; | |
61 | |
62 // Implements the GCM Client. It is used to coordinate MCS Client (communication | 42 // Implements the GCM Client. It is used to coordinate MCS Client (communication |
63 // with MCS) and other pieces of GCM infrastructure like Registration and | 43 // with MCS) and other pieces of GCM infrastructure like Registration and |
64 // Checkins. It also allows for registering user delegates that host | 44 // Checkins. It also allows for registering user delegates that host |
65 // applications that send and receive messages. | 45 // applications that send and receive messages. |
66 class GCM_EXPORT GCMClientImpl : public GCMClient { | 46 class GCM_EXPORT GCMClientImpl : public GCMClient { |
67 public: | 47 public: |
68 explicit GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder); | 48 explicit GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder); |
69 virtual ~GCMClientImpl(); | 49 virtual ~GCMClientImpl(); |
70 | 50 |
71 // Overridden from GCMClient: | 51 // Overridden from GCMClient: |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 239 |
260 // Factory for creating references in callbacks. | 240 // Factory for creating references in callbacks. |
261 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 241 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
262 | 242 |
263 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 243 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
264 }; | 244 }; |
265 | 245 |
266 } // namespace gcm | 246 } // namespace gcm |
267 | 247 |
268 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 248 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
OLD | NEW |