| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/memory/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/threading/non_thread_safe.h" | 9 #include "base/threading/non_thread_safe.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 FROM_HERE, | 294 FROM_HERE, |
| 295 base::Bind(&Connection::ReadData, weak_factory_.GetWeakPtr())); | 295 base::Bind(&Connection::ReadData, weak_factory_.GetWeakPtr())); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void SimpleHttpServer::Connection::WriteData() { | 298 void SimpleHttpServer::Connection::WriteData() { |
| 299 CHECK(CalledOnValidThread()); | 299 CHECK(CalledOnValidThread()); |
| 300 CHECK_GE(output_buffer_->capacity(), | 300 CHECK_GE(output_buffer_->capacity(), |
| 301 output_buffer_->offset() + bytes_to_write_) << "Overflow"; | 301 output_buffer_->offset() + bytes_to_write_) << "Overflow"; |
| 302 | 302 |
| 303 int write_result = socket_->Write( | 303 int write_result = socket_->Write( |
| 304 output_buffer_, | 304 output_buffer_.get(), |
| 305 bytes_to_write_, | 305 bytes_to_write_, |
| 306 base::Bind(&Connection::OnDataWritten, base::Unretained(this))); | 306 base::Bind(&Connection::OnDataWritten, base::Unretained(this))); |
| 307 | 307 |
| 308 if (write_result != net::ERR_IO_PENDING) | 308 if (write_result != net::ERR_IO_PENDING) |
| 309 OnDataWritten(write_result); | 309 OnDataWritten(write_result); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void SimpleHttpServer::Connection::OnDataWritten(int count) { | 312 void SimpleHttpServer::Connection::OnDataWritten(int count) { |
| 313 CHECK(CalledOnValidThread()); | 313 CHECK(CalledOnValidThread()); |
| 314 if (count < 0) { | 314 if (count < 0) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 530 |
| 531 void StopMockAdbServer() { | 531 void StopMockAdbServer() { |
| 532 BrowserThread::PostTaskAndReply( | 532 BrowserThread::PostTaskAndReply( |
| 533 BrowserThread::IO, | 533 BrowserThread::IO, |
| 534 FROM_HERE, | 534 FROM_HERE, |
| 535 base::Bind(&StopMockAdbServerOnIOThread), | 535 base::Bind(&StopMockAdbServerOnIOThread), |
| 536 base::MessageLoop::QuitClosure()); | 536 base::MessageLoop::QuitClosure()); |
| 537 content::RunMessageLoop(); | 537 content::RunMessageLoop(); |
| 538 } | 538 } |
| 539 | 539 |
| OLD | NEW |