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" |
(...skipping 30 matching lines...) Expand all Loading... |
41 const std::string& token) OVERRIDE; | 41 const std::string& token) OVERRIDE; |
42 | 42 |
43 // URLFetcherDelegate implementation. | 43 // URLFetcherDelegate implementation. |
44 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 44 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
45 | 45 |
46 protected: | 46 protected: |
47 void ResetRegisterBackoffEntryForTest( | 47 void ResetRegisterBackoffEntryForTest( |
48 const net::BackoffEntry::Policy* policy); | 48 const net::BackoffEntry::Policy* policy); |
49 | 49 |
50 private: | 50 private: |
| 51 friend class GCMNetworkChannelTest; |
51 void Register(); | 52 void Register(); |
52 void OnRegisterComplete(const std::string& registration_id, | 53 void OnRegisterComplete(const std::string& registration_id, |
53 gcm::GCMClient::Result result); | 54 gcm::GCMClient::Result result); |
54 void RequestAccessToken(); | 55 void RequestAccessToken(); |
55 void OnGetTokenComplete(const GoogleServiceAuthError& error, | 56 void OnGetTokenComplete(const GoogleServiceAuthError& error, |
56 const std::string& token); | 57 const std::string& token); |
57 GURL BuildUrl(); | 58 static GURL BuildUrl(const std::string& registration_id); |
58 | 59 |
59 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 60 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
60 scoped_ptr<GCMNetworkChannelDelegate> delegate_; | 61 scoped_ptr<GCMNetworkChannelDelegate> delegate_; |
61 | 62 |
62 // Message is saved until all conditions are met: there is valid | 63 // Message is saved until all conditions are met: there is valid |
63 // registration_id and access_token. | 64 // registration_id and access_token. |
64 std::string encoded_message_; | 65 std::string encoded_message_; |
65 | 66 |
66 // Access token is saved because in case of auth failure from server we need | 67 // Access token is saved because in case of auth failure from server we need |
67 // to invalidate it. | 68 // to invalidate it. |
68 std::string access_token_; | 69 std::string access_token_; |
69 | 70 |
70 // GCM registration_id is requested one at startup and never refreshed until | 71 // GCM registration_id is requested one at startup and never refreshed until |
71 // next restart. | 72 // next restart. |
72 std::string registration_id_; | 73 std::string registration_id_; |
73 scoped_ptr<net::BackoffEntry> register_backoff_entry_; | 74 scoped_ptr<net::BackoffEntry> register_backoff_entry_; |
74 | 75 |
75 scoped_ptr<net::URLFetcher> fetcher_; | 76 scoped_ptr<net::URLFetcher> fetcher_; |
76 | 77 |
77 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; | 78 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; |
78 | 79 |
79 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); | 80 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); |
80 }; | 81 }; |
81 | 82 |
82 } // namespace syncer | 83 } // namespace syncer |
83 | 84 |
84 #endif // SYNC_NOTIFIER_GCM_NETWORK_CHANNEL_H_ | 85 #endif // SYNC_NOTIFIER_GCM_NETWORK_CHANNEL_H_ |
OLD | NEW |