OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 // Simple system resources class that uses the current message loop | 5 // Simple system resources class that uses the current message loop |
6 // for scheduling. Assumes the current message loop is already | 6 // for scheduling. Assumes the current message loop is already |
7 // running. | 7 // running. |
8 | 8 |
9 #ifndef SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ | 9 #ifndef SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ |
10 #define SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ | 10 #define SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ |
11 | 11 |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
21 #include "google/cacheinvalidation/include/system-resources.h" | 21 #include "google/cacheinvalidation/include/system-resources.h" |
| 22 #include "jingle/notifier/base/notifier_options.h" |
22 #include "sync/base/sync_export.h" | 23 #include "sync/base/sync_export.h" |
23 #include "sync/notifier/invalidator_state.h" | 24 #include "sync/notifier/invalidator_state.h" |
24 #include "sync/notifier/state_writer.h" | 25 #include "sync/notifier/state_writer.h" |
25 | 26 |
26 namespace syncer { | 27 namespace syncer { |
27 | 28 |
28 class SyncLogger : public invalidation::Logger { | 29 class SyncLogger : public invalidation::Logger { |
29 public: | 30 public: |
30 SyncLogger(); | 31 SyncLogger(); |
31 | 32 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 virtual void SetMessageReceiver( | 104 virtual void SetMessageReceiver( |
104 invalidation::MessageCallback* incoming_receiver) OVERRIDE; | 105 invalidation::MessageCallback* incoming_receiver) OVERRIDE; |
105 virtual void AddNetworkStatusReceiver( | 106 virtual void AddNetworkStatusReceiver( |
106 invalidation::NetworkStatusCallback* network_status_receiver) OVERRIDE; | 107 invalidation::NetworkStatusCallback* network_status_receiver) OVERRIDE; |
107 virtual void SetSystemResources( | 108 virtual void SetSystemResources( |
108 invalidation::SystemResources* resources) OVERRIDE; | 109 invalidation::SystemResources* resources) OVERRIDE; |
109 | 110 |
110 // Subclass should implement SendEncodedMessage to send encoded message to | 111 // Subclass should implement SendEncodedMessage to send encoded message to |
111 // Tango over network. | 112 // Tango over network. |
112 virtual void SendEncodedMessage(const std::string& encoded_message) = 0; | 113 virtual void SendEncodedMessage(const std::string& encoded_message) = 0; |
| 114 virtual void UpdateCredentials(const std::string& email, |
| 115 const std::string& token) = 0; |
113 | 116 |
114 // Classes interested in network channel state changes should implement | 117 // Classes interested in network channel state changes should implement |
115 // SyncNetworkChannel::Observer and register here. | 118 // SyncNetworkChannel::Observer and register here. |
116 void AddObserver(Observer* observer); | 119 void AddObserver(Observer* observer); |
117 void RemoveObserver(Observer* observer); | 120 void RemoveObserver(Observer* observer); |
118 | 121 |
| 122 // Helper functions that know how to construct network channels from channel |
| 123 // specific parameters. |
| 124 static scoped_ptr<SyncNetworkChannel> CreatePushClientChannel( |
| 125 const notifier::NotifierOptions& notifier_options); |
| 126 static scoped_ptr<SyncNetworkChannel> CreateGCMNetworkChannel(); |
| 127 |
119 const std::string& GetServiceContextForTest() const; | 128 const std::string& GetServiceContextForTest() const; |
120 | 129 |
121 int64 GetSchedulingHashForTest() const; | 130 int64 GetSchedulingHashForTest() const; |
122 | 131 |
123 static std::string EncodeMessageForTest( | 132 static std::string EncodeMessageForTest( |
124 const std::string& message, | 133 const std::string& message, |
125 const std::string& service_context, | 134 const std::string& service_context, |
126 int64 scheduling_hash); | 135 int64 scheduling_hash); |
127 | 136 |
128 static bool DecodeMessageForTest( | 137 static bool DecodeMessageForTest( |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 scoped_ptr<SyncInvalidationScheduler> internal_scheduler_; | 243 scoped_ptr<SyncInvalidationScheduler> internal_scheduler_; |
235 scoped_ptr<SyncInvalidationScheduler> listener_scheduler_; | 244 scoped_ptr<SyncInvalidationScheduler> listener_scheduler_; |
236 scoped_ptr<SyncStorage> storage_; | 245 scoped_ptr<SyncStorage> storage_; |
237 // sync_network_channel_ is owned by SyncInvalidationListener. | 246 // sync_network_channel_ is owned by SyncInvalidationListener. |
238 SyncNetworkChannel* sync_network_channel_; | 247 SyncNetworkChannel* sync_network_channel_; |
239 }; | 248 }; |
240 | 249 |
241 } // namespace syncer | 250 } // namespace syncer |
242 | 251 |
243 #endif // SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ | 252 #endif // SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ |
OLD | NEW |