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

Side by Side Diff: google_apis/gcm/engine/connection_handler_impl.cc

Issue 2427633005: Improve GCM enum switch type safety (Closed)
Patch Set: Rebase Created 4 years, 2 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
« no previous file with comments | « google_apis/gcm/engine/checkin_request.cc ('k') | google_apis/gcm/engine/mcs_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "google_apis/gcm/engine/connection_handler_impl.h" 5 #include "google_apis/gcm/engine/connection_handler_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 min_bytes_needed = message_size_; 222 min_bytes_needed = message_size_;
223 max_bytes_needed = message_size_; 223 max_bytes_needed = message_size_;
224 } else { 224 } else {
225 int bytes_left = message_size_ - payload_input_buffer_.size(); 225 int bytes_left = message_size_ - payload_input_buffer_.size();
226 if (bytes_left > kDefaultDataPacketLimit) 226 if (bytes_left > kDefaultDataPacketLimit)
227 bytes_left = kDefaultDataPacketLimit; 227 bytes_left = kDefaultDataPacketLimit;
228 min_bytes_needed = bytes_left; 228 min_bytes_needed = bytes_left;
229 max_bytes_needed = bytes_left; 229 max_bytes_needed = bytes_left;
230 } 230 }
231 break; 231 break;
232 default:
233 NOTREACHED();
234 } 232 }
235 DCHECK_GE(max_bytes_needed, min_bytes_needed); 233 DCHECK_GE(max_bytes_needed, min_bytes_needed);
236 234
237 int unread_byte_count = input_stream_->UnreadByteCount(); 235 int unread_byte_count = input_stream_->UnreadByteCount();
238 if (min_bytes_needed > unread_byte_count && 236 if (min_bytes_needed > unread_byte_count &&
239 input_stream_->Refresh( 237 input_stream_->Refresh(
240 base::Bind(&ConnectionHandlerImpl::WaitForData, 238 base::Bind(&ConnectionHandlerImpl::WaitForData,
241 weak_ptr_factory_.GetWeakPtr(), 239 weak_ptr_factory_.GetWeakPtr(),
242 state), 240 state),
243 max_bytes_needed - unread_byte_count) == net::ERR_IO_PENDING) { 241 max_bytes_needed - unread_byte_count) == net::ERR_IO_PENDING) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 break; 276 break;
279 case MCS_TAG_AND_SIZE: 277 case MCS_TAG_AND_SIZE:
280 OnGotMessageTag(); 278 OnGotMessageTag();
281 break; 279 break;
282 case MCS_SIZE: 280 case MCS_SIZE:
283 OnGotMessageSize(); 281 OnGotMessageSize();
284 break; 282 break;
285 case MCS_PROTO_BYTES: 283 case MCS_PROTO_BYTES:
286 OnGotMessageBytes(); 284 OnGotMessageBytes();
287 break; 285 break;
288 default:
289 NOTREACHED();
290 } 286 }
291 } 287 }
292 288
293 void ConnectionHandlerImpl::OnGotVersion() { 289 void ConnectionHandlerImpl::OnGotVersion() {
294 uint8_t version = 0; 290 uint8_t version = 0;
295 { 291 {
296 CodedInputStream coded_input_stream(input_stream_.get()); 292 CodedInputStream coded_input_stream(input_stream_.get());
297 coded_input_stream.ReadRaw(&version, 1); 293 coded_input_stream.ReadRaw(&version, 1);
298 } 294 }
299 // TODO(zea): remove this when the server is ready. 295 // TODO(zea): remove this when the server is ready.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 message_tag_ = 0; 487 message_tag_ = 0;
492 message_size_ = 0; 488 message_size_ = 0;
493 size_packet_so_far_ = 0; 489 size_packet_so_far_ = 0;
494 payload_input_buffer_.clear(); 490 payload_input_buffer_.clear();
495 input_stream_.reset(); 491 input_stream_.reset();
496 output_stream_.reset(); 492 output_stream_.reset();
497 weak_ptr_factory_.InvalidateWeakPtrs(); 493 weak_ptr_factory_.InvalidateWeakPtrs();
498 } 494 }
499 495
500 } // namespace gcm 496 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/checkin_request.cc ('k') | google_apis/gcm/engine/mcs_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698