OLD | NEW |
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/base/socket_stream.h" | 5 #include "google_apis/gcm/base/socket_stream.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/profiler/scoped_profile.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/socket/stream_socket.h" | 11 #include "net/socket/stream_socket.h" |
12 | 12 |
13 namespace gcm { | 13 namespace gcm { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // TODO(zea): consider having dynamically-sized buffers if this becomes too | 17 // TODO(zea): consider having dynamically-sized buffers if this becomes too |
18 // expensive. | 18 // expensive. |
19 const uint32 kDefaultBufferSize = 8*1024; | 19 const uint32 kDefaultBufferSize = 8*1024; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 DCHECK_EQ(last_error_, net::OK); | 157 DCHECK_EQ(last_error_, net::OK); |
158 if (read_buffer_->BytesConsumed() == next_pos_) | 158 if (read_buffer_->BytesConsumed() == next_pos_) |
159 return EMPTY; | 159 return EMPTY; |
160 | 160 |
161 return READY; | 161 return READY; |
162 } | 162 } |
163 | 163 |
164 void SocketInputStream::RefreshCompletionCallback( | 164 void SocketInputStream::RefreshCompletionCallback( |
165 const base::Closure& callback, int result) { | 165 const base::Closure& callback, int result) { |
166 // TODO(vadimt): Remove ScopedProfile below once crbug.com/418183 is fixed. | 166 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. |
167 tracked_objects::ScopedProfile tracking_profile( | 167 tracked_objects::ScopedTracker tracking_profile( |
168 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 168 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
169 "418183 DoReadCallback => SocketInputStream::RefreshCompletionC...")); | 169 "418183 DoReadCallback => SocketInputStream::RefreshCompletionC...")); |
170 | 170 |
171 // If an error occurred before the completion callback could complete, ignore | 171 // If an error occurred before the completion callback could complete, ignore |
172 // the result. | 172 // the result. |
173 if (GetState() == CLOSED) | 173 if (GetState() == CLOSED) |
174 return; | 174 return; |
175 | 175 |
176 // Result == 0 implies EOF, which is treated as an error. | 176 // Result == 0 implies EOF, which is treated as an error. |
177 if (result == 0) | 177 if (result == 0) |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } | 334 } |
335 | 335 |
336 DVLOG(1) << "Socket flush complete."; | 336 DVLOG(1) << "Socket flush complete."; |
337 write_buffer_->SetOffset(0); | 337 write_buffer_->SetOffset(0); |
338 next_pos_ = 0; | 338 next_pos_ = 0; |
339 if (!callback.is_null()) | 339 if (!callback.is_null()) |
340 callback.Run(); | 340 callback.Run(); |
341 } | 341 } |
342 | 342 |
343 } // namespace gcm | 343 } // namespace gcm |
OLD | NEW |