| 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 #ifndef SYNC_NOTIFIER_GCM_NETWORK_CHANNEL_H_ | 5 #ifndef COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_H_ |
| 6 #define SYNC_NOTIFIER_GCM_NETWORK_CHANNEL_H_ | 6 #define COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "components/invalidation/gcm_network_channel_delegate.h" |
| 15 #include "components/invalidation/invalidation_export.h" |
| 16 #include "components/invalidation/sync_system_resources.h" |
| 14 #include "net/base/backoff_entry.h" | 17 #include "net/base/backoff_entry.h" |
| 15 #include "net/base/network_change_notifier.h" | 18 #include "net/base/network_change_notifier.h" |
| 16 #include "net/url_request/url_fetcher_delegate.h" | 19 #include "net/url_request/url_fetcher_delegate.h" |
| 17 #include "sync/base/sync_export.h" | |
| 18 #include "sync/notifier/gcm_network_channel_delegate.h" | |
| 19 #include "sync/notifier/sync_system_resources.h" | |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 class GoogleServiceAuthError; | 22 class GoogleServiceAuthError; |
| 23 | 23 |
| 24 namespace syncer { | 24 namespace syncer { |
| 25 class GCMNetworkChannel; | 25 class GCMNetworkChannel; |
| 26 | 26 |
| 27 // POD with copy of some statuses for debugging purposes. | 27 // POD with copy of some statuses for debugging purposes. |
| 28 struct GCMNetworkChannelDiagnostic { | 28 struct GCMNetworkChannelDiagnostic { |
| 29 explicit GCMNetworkChannelDiagnostic(GCMNetworkChannel* parent); | 29 explicit GCMNetworkChannelDiagnostic(GCMNetworkChannel* parent); |
| 30 | 30 |
| 31 // Collect all the internal variables in a single readable dictionary. | 31 // Collect all the internal variables in a single readable dictionary. |
| 32 scoped_ptr<base::DictionaryValue> CollectDebugData() const; | 32 scoped_ptr<base::DictionaryValue> CollectDebugData() const; |
| 33 | 33 |
| 34 // TODO(pavely): Move this toString to a more appropiate place in GCMClient. | 34 // TODO(pavely): Move this toString to a more appropiate place in GCMClient. |
| 35 std::string GCMClientResultToString( | 35 std::string GCMClientResultToString( |
| 36 const gcm::GCMClient::Result result) const; | 36 const gcm::GCMClient::Result result) const; |
| 37 | 37 |
| 38 GCMNetworkChannel* parent_; | 38 GCMNetworkChannel* parent_; |
| 39 bool last_message_empty_echo_token_; | 39 bool last_message_empty_echo_token_; |
| 40 base::Time last_message_received_time_; | 40 base::Time last_message_received_time_; |
| 41 int last_post_response_code_; | 41 int last_post_response_code_; |
| 42 std::string registration_id_; | 42 std::string registration_id_; |
| 43 gcm::GCMClient::Result registration_result_; | 43 gcm::GCMClient::Result registration_result_; |
| 44 int sent_messages_count_; | 44 int sent_messages_count_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // GCMNetworkChannel is an implementation of SyncNetworkChannel that routes | 47 // GCMNetworkChannel is an implementation of SyncNetworkChannel that routes |
| 48 // messages through GCMService. | 48 // messages through GCMService. |
| 49 class SYNC_EXPORT_PRIVATE GCMNetworkChannel | 49 class INVALIDATION_EXPORT_PRIVATE GCMNetworkChannel |
| 50 : public SyncNetworkChannel, | 50 : public SyncNetworkChannel, |
| 51 public net::URLFetcherDelegate, | 51 public net::URLFetcherDelegate, |
| 52 public net::NetworkChangeNotifier::NetworkChangeObserver, | 52 public net::NetworkChangeNotifier::NetworkChangeObserver, |
| 53 public base::NonThreadSafe { | 53 public base::NonThreadSafe { |
| 54 public: | 54 public: |
| 55 GCMNetworkChannel( | 55 GCMNetworkChannel( |
| 56 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 56 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 57 scoped_ptr<GCMNetworkChannelDelegate> delegate); | 57 scoped_ptr<GCMNetworkChannelDelegate> delegate); |
| 58 | 58 |
| 59 virtual ~GCMNetworkChannel(); | 59 virtual ~GCMNetworkChannel(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 GCMNetworkChannelDiagnostic diagnostic_info_; | 126 GCMNetworkChannelDiagnostic diagnostic_info_; |
| 127 | 127 |
| 128 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; | 128 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; |
| 129 | 129 |
| 130 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); | 130 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 } // namespace syncer | 133 } // namespace syncer |
| 134 | 134 |
| 135 #endif // SYNC_NOTIFIER_GCM_NETWORK_CHANNEL_H_ | 135 #endif // COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_H_ |
| OLD | NEW |