| 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 COMPONENTS_INVALIDATION_IMPL_GCM_NETWORK_CHANNEL_H_ | 5 #ifndef COMPONENTS_INVALIDATION_IMPL_GCM_NETWORK_CHANNEL_H_ |
| 6 #define COMPONENTS_INVALIDATION_IMPL_GCM_NETWORK_CHANNEL_H_ | 6 #define COMPONENTS_INVALIDATION_IMPL_GCM_NETWORK_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/sequence_checker.h" |
| 14 #include "components/invalidation/impl/gcm_network_channel_delegate.h" | 14 #include "components/invalidation/impl/gcm_network_channel_delegate.h" |
| 15 #include "components/invalidation/impl/sync_system_resources.h" | 15 #include "components/invalidation/impl/sync_system_resources.h" |
| 16 #include "components/invalidation/public/invalidation_export.h" | 16 #include "components/invalidation/public/invalidation_export.h" |
| 17 #include "net/base/backoff_entry.h" | 17 #include "net/base/backoff_entry.h" |
| 18 #include "net/base/network_change_notifier.h" | 18 #include "net/base/network_change_notifier.h" |
| 19 #include "net/url_request/url_fetcher_delegate.h" | 19 #include "net/url_request/url_fetcher_delegate.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 class GoogleServiceAuthError; | 22 class GoogleServiceAuthError; |
| 23 | 23 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 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 INVALIDATION_EXPORT GCMNetworkChannel | 49 class INVALIDATION_EXPORT 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 { | |
| 54 public: | 53 public: |
| 55 GCMNetworkChannel( | 54 GCMNetworkChannel( |
| 56 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 55 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 57 std::unique_ptr<GCMNetworkChannelDelegate> delegate); | 56 std::unique_ptr<GCMNetworkChannelDelegate> delegate); |
| 58 | 57 |
| 59 ~GCMNetworkChannel() override; | 58 ~GCMNetworkChannel() override; |
| 60 | 59 |
| 61 // invalidation::NetworkChannel implementation. | 60 // invalidation::NetworkChannel implementation. |
| 62 void SendMessage(const std::string& message) override; | 61 void SendMessage(const std::string& message) override; |
| 63 void SetMessageReceiver( | 62 void SetMessageReceiver( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // GCM and shuld include it in headers with outgoing message over http. | 119 // GCM and shuld include it in headers with outgoing message over http. |
| 121 std::string echo_token_; | 120 std::string echo_token_; |
| 122 | 121 |
| 123 // State of gcm and http channels. GCMNetworkChannel will only report | 122 // State of gcm and http channels. GCMNetworkChannel will only report |
| 124 // INVALIDATIONS_ENABLED if both channels are online. | 123 // INVALIDATIONS_ENABLED if both channels are online. |
| 125 bool gcm_channel_online_; | 124 bool gcm_channel_online_; |
| 126 bool http_channel_online_; | 125 bool http_channel_online_; |
| 127 | 126 |
| 128 GCMNetworkChannelDiagnostic diagnostic_info_; | 127 GCMNetworkChannelDiagnostic diagnostic_info_; |
| 129 | 128 |
| 129 SEQUENCE_CHECKER(sequence_checker_); |
| 130 |
| 130 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; | 131 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; |
| 131 | 132 |
| 132 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); | 133 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 } // namespace syncer | 136 } // namespace syncer |
| 136 | 137 |
| 137 #endif // COMPONENTS_INVALIDATION_IMPL_GCM_NETWORK_CHANNEL_H_ | 138 #endif // COMPONENTS_INVALIDATION_IMPL_GCM_NETWORK_CHANNEL_H_ |
| OLD | NEW |