Chromium Code Reviews| 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 "jingle/notifier/base/notifier_options.h" |
| 23 #include "sync/base/sync_export.h" | 23 #include "sync/base/sync_export.h" |
| 24 #include "sync/notifier/invalidator_state.h" | 24 #include "sync/notifier/invalidator_state.h" |
| 25 #include "sync/notifier/state_writer.h" | 25 #include "sync/notifier/state_writer.h" |
| 26 | 26 |
| 27 namespace syncer { | 27 namespace syncer { |
| 28 | 28 |
| 29 class GCMNetworkChannelDelegate; | |
| 30 | |
| 29 class SyncLogger : public invalidation::Logger { | 31 class SyncLogger : public invalidation::Logger { |
| 30 public: | 32 public: |
| 31 SyncLogger(); | 33 SyncLogger(); |
| 32 | 34 |
| 33 virtual ~SyncLogger(); | 35 virtual ~SyncLogger(); |
| 34 | 36 |
| 35 // invalidation::Logger implementation. | 37 // invalidation::Logger implementation. |
| 36 virtual void Log(LogLevel level, const char* file, int line, | 38 virtual void Log(LogLevel level, const char* file, int line, |
| 37 const char* format, ...) OVERRIDE; | 39 const char* format, ...) OVERRIDE; |
| 38 | 40 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 | 118 |
| 117 // Classes interested in network channel state changes should implement | 119 // Classes interested in network channel state changes should implement |
| 118 // SyncNetworkChannel::Observer and register here. | 120 // SyncNetworkChannel::Observer and register here. |
| 119 void AddObserver(Observer* observer); | 121 void AddObserver(Observer* observer); |
| 120 void RemoveObserver(Observer* observer); | 122 void RemoveObserver(Observer* observer); |
| 121 | 123 |
| 122 // Helper functions that know how to construct network channels from channel | 124 // Helper functions that know how to construct network channels from channel |
| 123 // specific parameters. | 125 // specific parameters. |
| 124 static scoped_ptr<SyncNetworkChannel> CreatePushClientChannel( | 126 static scoped_ptr<SyncNetworkChannel> CreatePushClientChannel( |
| 125 const notifier::NotifierOptions& notifier_options); | 127 const notifier::NotifierOptions& notifier_options); |
| 126 static scoped_ptr<SyncNetworkChannel> CreateGCMNetworkChannel(); | 128 static scoped_ptr<SyncNetworkChannel> CreateGCMNetworkChannel( |
| 129 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | |
| 130 scoped_ptr<GCMNetworkChannelDelegate> delegate); | |
| 127 | 131 |
| 128 const std::string& GetServiceContextForTest() const; | 132 const std::string& GetServiceContextForTest() const; |
| 129 | 133 |
| 130 int64 GetSchedulingHashForTest() const; | 134 int64 GetSchedulingHashForTest() const; |
| 131 | 135 |
| 132 static std::string EncodeMessageForTest( | 136 static std::string EncodeMessageForTest( |
| 133 const std::string& message, | 137 const std::string& message, |
| 134 const std::string& service_context, | 138 const std::string& service_context, |
| 135 int64 scheduling_hash); | 139 int64 scheduling_hash); |
| 136 | 140 |
| 137 static bool DecodeMessageForTest( | 141 static bool DecodeMessageForTest( |
| 138 const std::string& notification, | 142 const std::string& notification, |
| 139 std::string* message, | 143 std::string* message, |
| 140 std::string* service_context, | 144 std::string* service_context, |
| 141 int64* scheduling_hash); | 145 int64* scheduling_hash); |
| 142 | 146 |
| 143 protected: | 147 protected: |
| 144 // Subclass should notify about connection state through NotifyStateChange. | 148 // Subclass should notify about connection state through SetNetworkState. |
| 145 void NotifyStateChange(InvalidatorState invalidator_state); | 149 void SetNetworkState(InvalidatorState invalidator_state); |
|
rlarocque
2014/01/16 18:52:48
Is this change related to your efforts to make sta
pavely
2014/01/17 00:44:39
One scenario that I considered was to use this fun
| |
| 146 // Subclass should call DeliverIncomingMessage for message to reach | 150 // Subclass should call DeliverIncomingMessage for message to reach |
| 147 // invalidations library. | 151 // invalidations library. |
| 148 void DeliverIncomingMessage(const std::string& message); | 152 void DeliverIncomingMessage(const std::string& message); |
| 149 | 153 |
| 150 private: | 154 private: |
| 151 typedef std::vector<invalidation::NetworkStatusCallback*> | 155 typedef std::vector<invalidation::NetworkStatusCallback*> |
| 152 NetworkStatusReceiverList; | 156 NetworkStatusReceiverList; |
| 153 | 157 |
| 154 static void EncodeMessage( | 158 static void EncodeMessage( |
| 155 std::string* encoded_message, | 159 std::string* encoded_message, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 scoped_ptr<SyncInvalidationScheduler> internal_scheduler_; | 247 scoped_ptr<SyncInvalidationScheduler> internal_scheduler_; |
| 244 scoped_ptr<SyncInvalidationScheduler> listener_scheduler_; | 248 scoped_ptr<SyncInvalidationScheduler> listener_scheduler_; |
| 245 scoped_ptr<SyncStorage> storage_; | 249 scoped_ptr<SyncStorage> storage_; |
| 246 // sync_network_channel_ is owned by SyncInvalidationListener. | 250 // sync_network_channel_ is owned by SyncInvalidationListener. |
| 247 SyncNetworkChannel* sync_network_channel_; | 251 SyncNetworkChannel* sync_network_channel_; |
| 248 }; | 252 }; |
| 249 | 253 |
| 250 } // namespace syncer | 254 } // namespace syncer |
| 251 | 255 |
| 252 #endif // SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ | 256 #endif // SYNC_NOTIFIER_SYNC_SYSTEM_RESOURCES_H_ |
| OLD | NEW |