| Index: chrome/browser/chromeos/drive/test_servers/http_connection.cc
|
| diff --git a/chrome/browser/chromeos/drive/test_servers/http_connection.cc b/chrome/browser/chromeos/drive/test_servers/http_connection.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..89535cc492a83230af32fefbbd03d73be6180117
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/drive/test_servers/http_connection.cc
|
| @@ -0,0 +1,37 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/chromeos/drive/test_servers/http_connection.h"
|
| +
|
| +#include <string>
|
| +#include "base/basictypes.h"
|
| +#include "chrome/browser/chromeos/drive/test_servers/http_request.h"
|
| +#include "chrome/browser/chromeos/drive/test_servers/http_response.h"
|
| +
|
| +namespace drive {
|
| +namespace test_servers {
|
| +
|
| +HttpConnection::HttpConnection(net::StreamListenSocket* socket,
|
| + const HandleRequestCallback& callback)
|
| + : socket_(socket),
|
| + callback_(callback) {
|
| +}
|
| +
|
| +HttpConnection::~HttpConnection() {
|
| +}
|
| +
|
| +void HttpConnection::SendResponse(scoped_ptr<HttpResponse> response) const {
|
| + const std::string response_string = response->ToResponseString();
|
| + socket_->Send(response_string.c_str(), response_string.length());
|
| +}
|
| +
|
| +void HttpConnection::ReceiveData(const char* data, size_t length) {
|
| + request_parser_.ProcessChunk(data, length);
|
| + while (request_parser_.ParseRequest() == HttpRequestParser::ACCEPTED) {
|
| + callback_.Run(this, request_parser_.GetRequest().Pass());
|
| + }
|
| +}
|
| +
|
| +} // namespace test_servers
|
| +} // namespace drive
|
|
|