OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/drive/test_servers/http_connection.h" |
| 6 |
| 7 #include <string> |
| 8 #include "base/basictypes.h" |
| 9 #include "chrome/browser/chromeos/drive/test_servers/http_request.h" |
| 10 #include "chrome/browser/chromeos/drive/test_servers/http_response.h" |
| 11 |
| 12 namespace drive { |
| 13 namespace test_servers { |
| 14 |
| 15 HttpConnection::HttpConnection(net::StreamListenSocket* socket, |
| 16 const HandleRequestCallback& callback) |
| 17 : socket_(socket), |
| 18 callback_(callback) { |
| 19 } |
| 20 |
| 21 HttpConnection::~HttpConnection() { |
| 22 } |
| 23 |
| 24 void HttpConnection::SendResponse(scoped_ptr<HttpResponse> response) const { |
| 25 const std::string response_string = response->ToResponseString(); |
| 26 socket_->Send(response_string.c_str(), response_string.length()); |
| 27 } |
| 28 |
| 29 void HttpConnection::ReceiveData(const std::string& data) { |
| 30 request_parser_.ProcessChunk(data); |
| 31 while (request_parser_.ParseRequest() == HttpRequestParser::ACCEPTED) { |
| 32 callback_.Run(this, request_parser_.GetRequest().Pass()); |
| 33 } |
| 34 } |
| 35 |
| 36 } // namespace test_servers |
| 37 } // namespace drive |
OLD | NEW |