| 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 SYNC_NOTIFIER_GCM_NETWORK_CHANNEL_H_ |
| 6 #define SYNC_NOTIFIER_GCM_NETWORK_CHANNEL_H_ | 6 #define SYNC_NOTIFIER_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 "net/base/backoff_entry.h" | 14 #include "net/base/backoff_entry.h" |
| 15 #include "net/base/network_change_notifier.h" |
| 15 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
| 16 #include "sync/base/sync_export.h" | 17 #include "sync/base/sync_export.h" |
| 17 #include "sync/notifier/gcm_network_channel_delegate.h" | 18 #include "sync/notifier/gcm_network_channel_delegate.h" |
| 18 #include "sync/notifier/sync_system_resources.h" | 19 #include "sync/notifier/sync_system_resources.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| 21 class GoogleServiceAuthError; | 22 class GoogleServiceAuthError; |
| 22 | 23 |
| 23 namespace syncer { | 24 namespace syncer { |
| 24 class GCMNetworkChannel; | 25 class GCMNetworkChannel; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 41 std::string registration_id_; | 42 std::string registration_id_; |
| 42 gcm::GCMClient::Result registration_result_; | 43 gcm::GCMClient::Result registration_result_; |
| 43 int sent_messages_count_; | 44 int sent_messages_count_; |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 // GCMNetworkChannel is an implementation of SyncNetworkChannel that routes | 47 // GCMNetworkChannel is an implementation of SyncNetworkChannel that routes |
| 47 // messages through GCMProfileService. | 48 // messages through GCMProfileService. |
| 48 class SYNC_EXPORT_PRIVATE GCMNetworkChannel | 49 class SYNC_EXPORT_PRIVATE GCMNetworkChannel |
| 49 : public SyncNetworkChannel, | 50 : public SyncNetworkChannel, |
| 50 public net::URLFetcherDelegate, | 51 public net::URLFetcherDelegate, |
| 52 public net::NetworkChangeNotifier::NetworkChangeObserver, |
| 51 public base::NonThreadSafe { | 53 public base::NonThreadSafe { |
| 52 public: | 54 public: |
| 53 GCMNetworkChannel( | 55 GCMNetworkChannel( |
| 54 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 56 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 55 scoped_ptr<GCMNetworkChannelDelegate> delegate); | 57 scoped_ptr<GCMNetworkChannelDelegate> delegate); |
| 56 | 58 |
| 57 virtual ~GCMNetworkChannel(); | 59 virtual ~GCMNetworkChannel(); |
| 58 | 60 |
| 59 // invalidation::NetworkChannel implementation. | 61 // invalidation::NetworkChannel implementation. |
| 60 virtual void SendMessage(const std::string& message) OVERRIDE; | 62 virtual void SendMessage(const std::string& message) OVERRIDE; |
| 61 virtual void SetMessageReceiver( | 63 virtual void SetMessageReceiver( |
| 62 invalidation::MessageCallback* incoming_receiver) OVERRIDE; | 64 invalidation::MessageCallback* incoming_receiver) OVERRIDE; |
| 63 | 65 |
| 64 // SyncNetworkChannel implementation. | 66 // SyncNetworkChannel implementation. |
| 65 virtual void UpdateCredentials(const std::string& email, | 67 virtual void UpdateCredentials(const std::string& email, |
| 66 const std::string& token) OVERRIDE; | 68 const std::string& token) OVERRIDE; |
| 67 virtual void RequestDetailedStatus( | 69 virtual void RequestDetailedStatus( |
| 68 base::Callback<void(const base::DictionaryValue&)> callback) OVERRIDE; | 70 base::Callback<void(const base::DictionaryValue&)> callback) OVERRIDE; |
| 69 | 71 |
| 70 // URLFetcherDelegate implementation. | 72 // URLFetcherDelegate implementation. |
| 71 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 73 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 72 | 74 |
| 75 // NetworkChangeObserver implementation. |
| 76 virtual void OnNetworkChanged( |
| 77 net::NetworkChangeNotifier::ConnectionType connection_type) OVERRIDE; |
| 78 |
| 73 protected: | 79 protected: |
| 74 void ResetRegisterBackoffEntryForTest( | 80 void ResetRegisterBackoffEntryForTest( |
| 75 const net::BackoffEntry::Policy* policy); | 81 const net::BackoffEntry::Policy* policy); |
| 76 | 82 |
| 77 virtual GURL BuildUrl(const std::string& registration_id); | 83 virtual GURL BuildUrl(const std::string& registration_id); |
| 78 | 84 |
| 79 private: | 85 private: |
| 80 friend class GCMNetworkChannelTest; | 86 friend class GCMNetworkChannelTest; |
| 81 void Register(); | 87 void Register(); |
| 82 void OnRegisterComplete(const std::string& registration_id, | 88 void OnRegisterComplete(const std::string& registration_id, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 GCMNetworkChannelDiagnostic diagnostic_info_; | 125 GCMNetworkChannelDiagnostic diagnostic_info_; |
| 120 | 126 |
| 121 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; | 127 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; |
| 122 | 128 |
| 123 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); | 129 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); |
| 124 }; | 130 }; |
| 125 | 131 |
| 126 } // namespace syncer | 132 } // namespace syncer |
| 127 | 133 |
| 128 #endif // SYNC_NOTIFIER_GCM_NETWORK_CHANNEL_H_ | 134 #endif // SYNC_NOTIFIER_GCM_NETWORK_CHANNEL_H_ |
| OLD | NEW |