blob: 4adbf2fbc1094055ee1436d22d405beabae78663 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright (c) 2006-2008 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 "net/base/client_socket_handle.h"
#include "net/base/client_socket.h"
#include "net/base/client_socket_pool.h"
namespace net {
ClientSocketHandle::ClientSocketHandle(ClientSocketPool* pool)
: pool_(pool), socket_(NULL) {
}
ClientSocketHandle::~ClientSocketHandle() {
Reset();
}
int ClientSocketHandle::Init(const std::string& group_name,
CompletionCallback* callback) {
Reset();
group_name_ = group_name;
return pool_->RequestSocket(this, callback);
}
void ClientSocketHandle::Reset() {
if (group_name_.empty()) // Was Init called?
return;
if (socket_) {
pool_->ReleaseSocket(this);
socket_ = NULL;
} else {
pool_->CancelRequest(this);
}
group_name_.clear();
}
} // namespace net
|