Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / net / server / http_connection.cc
blobd433012cd651c7b7462972c3835cb818a9a78d8d
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 "net/server/http_connection.h"
7 #include "net/server/http_server.h"
8 #include "net/server/http_server_response_info.h"
9 #include "net/server/web_socket.h"
10 #include "net/socket/stream_listen_socket.h"
12 namespace net {
14 int HttpConnection::last_id_ = 0;
16 void HttpConnection::Send(const std::string& data) {
17 if (!socket_.get())
18 return;
19 socket_->Send(data);
22 void HttpConnection::Send(const char* bytes, int len) {
23 if (!socket_.get())
24 return;
25 socket_->Send(bytes, len);
28 void HttpConnection::Send(const HttpServerResponseInfo& response) {
29 Send(response.Serialize());
32 HttpConnection::HttpConnection(HttpServer* server,
33 scoped_ptr<StreamListenSocket> sock)
34 : server_(server),
35 socket_(sock.Pass()) {
36 id_ = last_id_++;
39 HttpConnection::~HttpConnection() {
40 server_->delegate_->OnClose(id_);
43 void HttpConnection::Shift(int num_bytes) {
44 recv_data_ = recv_data_.substr(num_bytes);
47 } // namespace net