Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: sync/notifier/sync_system_resources.cc

Issue 140513002: Client-to-server messages in GCMNetworkChannel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "sync/notifier/sync_system_resources.h" 5 #include "sync/notifier/sync_system_resources.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <cstring> 8 #include <cstring>
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "google/cacheinvalidation/client_gateway.pb.h" 17 #include "google/cacheinvalidation/client_gateway.pb.h"
18 #include "google/cacheinvalidation/deps/callback.h" 18 #include "google/cacheinvalidation/deps/callback.h"
19 #include "google/cacheinvalidation/include/types.h" 19 #include "google/cacheinvalidation/include/types.h"
20 #include "jingle/notifier/listener/push_client.h" 20 #include "jingle/notifier/listener/push_client.h"
21 #include "sync/notifier/gcm_network_channel.h" 21 #include "sync/notifier/gcm_network_channel.h"
22 #include "sync/notifier/gcm_network_channel_delegate.h"
22 #include "sync/notifier/invalidation_util.h" 23 #include "sync/notifier/invalidation_util.h"
23 #include "sync/notifier/push_client_channel.h" 24 #include "sync/notifier/push_client_channel.h"
24 25
25 namespace syncer { 26 namespace syncer {
26 27
27 SyncLogger::SyncLogger() {} 28 SyncLogger::SyncLogger() {}
28 SyncLogger::~SyncLogger() {} 29 SyncLogger::~SyncLogger() {}
29 30
30 void SyncLogger::Log(LogLevel level, const char* file, int line, 31 void SyncLogger::Log(LogLevel level, const char* file, int line,
31 const char* format, ...) { 32 const char* format, ...) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 173 }
173 174
174 scoped_ptr<SyncNetworkChannel> SyncNetworkChannel::CreatePushClientChannel( 175 scoped_ptr<SyncNetworkChannel> SyncNetworkChannel::CreatePushClientChannel(
175 const notifier::NotifierOptions& notifier_options) { 176 const notifier::NotifierOptions& notifier_options) {
176 scoped_ptr<notifier::PushClient> push_client( 177 scoped_ptr<notifier::PushClient> push_client(
177 notifier::PushClient::CreateDefaultOnIOThread(notifier_options)); 178 notifier::PushClient::CreateDefaultOnIOThread(notifier_options));
178 return scoped_ptr<SyncNetworkChannel>( 179 return scoped_ptr<SyncNetworkChannel>(
179 new PushClientChannel(push_client.Pass())); 180 new PushClientChannel(push_client.Pass()));
180 } 181 }
181 182
182 scoped_ptr<SyncNetworkChannel> SyncNetworkChannel::CreateGCMNetworkChannel() { 183 scoped_ptr<SyncNetworkChannel> SyncNetworkChannel::CreateGCMNetworkChannel(
183 return scoped_ptr<SyncNetworkChannel>(new GCMNetworkChannel()); 184 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
185 scoped_ptr<GCMNetworkChannelDelegate> delegate) {
186 return scoped_ptr<SyncNetworkChannel>(new GCMNetworkChannel(
187 request_context_getter, delegate.Pass()));
184 } 188 }
185 189
186 const std::string& SyncNetworkChannel::GetServiceContextForTest() const { 190 const std::string& SyncNetworkChannel::GetServiceContextForTest() const {
187 return service_context_; 191 return service_context_;
188 } 192 }
189 193
190 int64 SyncNetworkChannel::GetSchedulingHashForTest() const { 194 int64 SyncNetworkChannel::GetSchedulingHashForTest() const {
191 return scheduling_hash_; 195 return scheduling_hash_;
192 } 196 }
193 197
194 std::string SyncNetworkChannel::EncodeMessageForTest( 198 std::string SyncNetworkChannel::EncodeMessageForTest(
195 const std::string& message, const std::string& service_context, 199 const std::string& message, const std::string& service_context,
196 int64 scheduling_hash) { 200 int64 scheduling_hash) {
197 std::string encoded_message; 201 std::string encoded_message;
198 EncodeMessage(&encoded_message, message, service_context, scheduling_hash); 202 EncodeMessage(&encoded_message, message, service_context, scheduling_hash);
199 return encoded_message; 203 return encoded_message;
200 } 204 }
201 205
202 bool SyncNetworkChannel::DecodeMessageForTest( 206 bool SyncNetworkChannel::DecodeMessageForTest(
203 const std::string& data, 207 const std::string& data,
204 std::string* message, 208 std::string* message,
205 std::string* service_context, 209 std::string* service_context,
206 int64* scheduling_hash) { 210 int64* scheduling_hash) {
207 return DecodeMessage(data, message, service_context, scheduling_hash); 211 return DecodeMessage(data, message, service_context, scheduling_hash);
208 } 212 }
209 213
210 void SyncNetworkChannel::NotifyStateChange(InvalidatorState invalidator_state) { 214 void SyncNetworkChannel::SetNetworkState(InvalidatorState invalidator_state) {
211 // Remember state for future NetworkStatusReceivers. 215 if (invalidator_state_ == invalidator_state)
216 return;
212 invalidator_state_ = invalidator_state; 217 invalidator_state_ = invalidator_state;
213 // Notify NetworkStatusReceivers in cacheinvalidation. 218 // Notify NetworkStatusReceivers in cacheinvalidation.
214 for (NetworkStatusReceiverList::const_iterator it = 219 for (NetworkStatusReceiverList::const_iterator it =
215 network_status_receivers_.begin(); 220 network_status_receivers_.begin();
216 it != network_status_receivers_.end(); ++it) { 221 it != network_status_receivers_.end(); ++it) {
217 (*it)->Run(invalidator_state_ == INVALIDATIONS_ENABLED); 222 (*it)->Run(invalidator_state_ == INVALIDATIONS_ENABLED);
218 } 223 }
219 // Notify observers. 224 // Notify observers.
220 FOR_EACH_OBSERVER(Observer, observers_, 225 FOR_EACH_OBSERVER(Observer, observers_,
221 OnNetworkChannelStateChanged(invalidator_state_)); 226 OnNetworkChannelStateChanged(invalidator_state_));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 394
390 SyncInvalidationScheduler* SyncSystemResources::internal_scheduler() { 395 SyncInvalidationScheduler* SyncSystemResources::internal_scheduler() {
391 return internal_scheduler_.get(); 396 return internal_scheduler_.get();
392 } 397 }
393 398
394 SyncInvalidationScheduler* SyncSystemResources::listener_scheduler() { 399 SyncInvalidationScheduler* SyncSystemResources::listener_scheduler() {
395 return listener_scheduler_.get(); 400 return listener_scheduler_.get();
396 } 401 }
397 402
398 } // namespace syncer 403 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698