OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/websockets/websocket_stream.h" | 5 #include "net/websockets/websocket_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/http/http_request_headers.h" | 9 #include "net/http/http_request_headers.h" |
10 #include "net/http/http_status_code.h" | 10 #include "net/http/http_status_code.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 // and so terminates the handshake if it is incomplete. | 63 // and so terminates the handshake if it is incomplete. |
64 virtual ~StreamRequestImpl() {} | 64 virtual ~StreamRequestImpl() {} |
65 | 65 |
66 URLRequest* url_request() { return &url_request_; } | 66 URLRequest* url_request() { return &url_request_; } |
67 | 67 |
68 void PerformUpgrade() { | 68 void PerformUpgrade() { |
69 connect_delegate_->OnSuccess(create_helper_->stream()->Upgrade()); | 69 connect_delegate_->OnSuccess(create_helper_->stream()->Upgrade()); |
70 } | 70 } |
71 | 71 |
72 void ReportFailure() { | 72 void ReportFailure() { |
73 connect_delegate_->OnFailure(kWebSocketErrorAbnormalClosure); | 73 std::string failure_message; |
74 if (create_helper_->stream()) | |
Adam Rice
2013/12/06 07:02:31
Calling url_request_.status().error() can give you
yhirano
2013/12/06 08:54:56
Done.
| |
75 failure_message = create_helper_->stream()->FailureMessage(); | |
76 connect_delegate_->OnFailure(failure_message); | |
74 } | 77 } |
75 | 78 |
76 private: | 79 private: |
77 // |delegate_| needs to be declared before |url_request_| so that it gets | 80 // |delegate_| needs to be declared before |url_request_| so that it gets |
78 // initialised first. | 81 // initialised first. |
79 scoped_ptr<Delegate> delegate_; | 82 scoped_ptr<Delegate> delegate_; |
80 | 83 |
81 // Deleting the StreamRequestImpl object deletes this URLRequest object, | 84 // Deleting the StreamRequestImpl object deletes this URLRequest object, |
82 // cancelling the whole connection. | 85 // cancelling the whole connection. |
83 URLRequest url_request_; | 86 URLRequest url_request_; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate) { | 193 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate) { |
191 return CreateAndConnectStreamWithCreateHelper(socket_url, | 194 return CreateAndConnectStreamWithCreateHelper(socket_url, |
192 create_helper.Pass(), | 195 create_helper.Pass(), |
193 origin, | 196 origin, |
194 url_request_context, | 197 url_request_context, |
195 net_log, | 198 net_log, |
196 connect_delegate.Pass()); | 199 connect_delegate.Pass()); |
197 } | 200 } |
198 | 201 |
199 } // namespace net | 202 } // namespace net |
OLD | NEW |