Fix build break
[chromium-blink-merge.git] / chrome / browser / google_apis / test_server / http_connection.cc
blobd870c7e31db766d051625ccfd9f3018bf150dff9
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.
5 #include "chrome/browser/google_apis/test_server/http_connection.h"
7 #include "chrome/browser/google_apis/test_server/http_response.h"
8 #include "net/socket/stream_listen_socket.h"
10 namespace google_apis {
11 namespace test_server {
13 HttpConnection::HttpConnection(net::StreamListenSocket* socket,
14 const HandleRequestCallback& callback)
15 : socket_(socket),
16 callback_(callback) {
19 HttpConnection::~HttpConnection() {
22 void HttpConnection::SendResponse(scoped_ptr<HttpResponse> response) const {
23 const std::string response_string = response->ToResponseString();
24 socket_->Send(response_string.c_str(), response_string.length());
27 void HttpConnection::ReceiveData(const base::StringPiece& data) {
28 request_parser_.ProcessChunk(data);
29 if (request_parser_.ParseRequest() == HttpRequestParser::ACCEPTED) {
30 callback_.Run(this, request_parser_.GetRequest());
34 } // namespace test_server
35 } // namespace google_apis