OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_host/socket_stream_host.h" | 5 #include "chrome/browser/renderer_host/socket_stream_host.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/common/net/socket_stream.h" | 8 #include "chrome/common/net/socket_stream.h" |
9 #include "net/socket_stream/socket_stream_job.h" | 9 #include "net/socket_stream/socket_stream_job.h" |
10 | 10 |
11 static const char* kSocketIdKey = "socketId"; | 11 static const char* kSocketIdKey = "socketId"; |
(...skipping 26 matching lines...) Expand all Loading... |
38 } | 38 } |
39 return chrome_common_net::kNoSocketId; | 39 return chrome_common_net::kNoSocketId; |
40 } | 40 } |
41 | 41 |
42 SocketStreamHost::~SocketStreamHost() { | 42 SocketStreamHost::~SocketStreamHost() { |
43 VLOG(1) << "SocketStreamHost destructed socket_id=" << socket_id_; | 43 VLOG(1) << "SocketStreamHost destructed socket_id=" << socket_id_; |
44 socket_->DetachDelegate(); | 44 socket_->DetachDelegate(); |
45 } | 45 } |
46 | 46 |
47 void SocketStreamHost::Connect(const GURL& url, | 47 void SocketStreamHost::Connect(const GURL& url, |
48 URLRequestContext* request_context) { | 48 net::URLRequestContext* request_context) { |
49 VLOG(1) << "SocketStreamHost::Connect url=" << url; | 49 VLOG(1) << "SocketStreamHost::Connect url=" << url; |
50 socket_ = net::SocketStreamJob::CreateSocketStreamJob(url, delegate_); | 50 socket_ = net::SocketStreamJob::CreateSocketStreamJob(url, delegate_); |
51 socket_->set_context(request_context); | 51 socket_->set_context(request_context); |
52 socket_->SetUserData(kSocketIdKey, new SocketStreamId(socket_id_)); | 52 socket_->SetUserData(kSocketIdKey, new SocketStreamId(socket_id_)); |
53 socket_->Connect(); | 53 socket_->Connect(); |
54 } | 54 } |
55 | 55 |
56 bool SocketStreamHost::SendData(const std::vector<char>& data) { | 56 bool SocketStreamHost::SendData(const std::vector<char>& data) { |
57 VLOG(1) << "SocketStreamHost::SendData"; | 57 VLOG(1) << "SocketStreamHost::SendData"; |
58 return socket_ && socket_->SendData(&data[0], data.size()); | 58 return socket_ && socket_->SendData(&data[0], data.size()); |
59 } | 59 } |
60 | 60 |
61 void SocketStreamHost::Close() { | 61 void SocketStreamHost::Close() { |
62 VLOG(1) << "SocketStreamHost::Close"; | 62 VLOG(1) << "SocketStreamHost::Close"; |
63 if (!socket_) | 63 if (!socket_) |
64 return; | 64 return; |
65 socket_->Close(); | 65 socket_->Close(); |
66 } | 66 } |
OLD | NEW |