| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_socket.h" | 5 #include "extensions/browser/api/cast_channel/cast_socket.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 VLOG_WITH_CONNECTION(2) << "DoReadComplete result = " << result; | 846 VLOG_WITH_CONNECTION(2) << "DoReadComplete result = " << result; |
| 847 | 847 |
| 848 if (result <= 0) { // 0 means EOF: the peer closed the socket | 848 if (result <= 0) { // 0 means EOF: the peer closed the socket |
| 849 VLOG_WITH_CONNECTION(1) << "Read error, peer closed the socket"; | 849 VLOG_WITH_CONNECTION(1) << "Read error, peer closed the socket"; |
| 850 SetErrorState(CHANNEL_ERROR_SOCKET_ERROR); | 850 SetErrorState(CHANNEL_ERROR_SOCKET_ERROR); |
| 851 SetReadState(READ_STATE_ERROR); | 851 SetReadState(READ_STATE_ERROR); |
| 852 return result == 0 ? net::ERR_FAILED : result; | 852 return result == 0 ? net::ERR_FAILED : result; |
| 853 } | 853 } |
| 854 | 854 |
| 855 size_t message_size; | 855 size_t message_size; |
| 856 DCHECK(current_message_.get() == NULL); | 856 DCHECK(current_message_.get() == nullptr); |
| 857 current_message_ = framer_->Ingest(result, &message_size, &error_state_); | 857 current_message_ = framer_->Ingest(result, &message_size, &error_state_); |
| 858 if (current_message_.get()) { | 858 if (current_message_.get()) { |
| 859 DCHECK_EQ(error_state_, CHANNEL_ERROR_NONE); | 859 DCHECK_EQ(error_state_, CHANNEL_ERROR_NONE); |
| 860 DCHECK_GT(message_size, static_cast<size_t>(0)); | 860 DCHECK_GT(message_size, static_cast<size_t>(0)); |
| 861 logger_->LogSocketEventForMessage( | 861 logger_->LogSocketEventForMessage( |
| 862 channel_id_, | 862 channel_id_, |
| 863 proto::MESSAGE_READ, | 863 proto::MESSAGE_READ, |
| 864 current_message_->namespace_(), | 864 current_message_->namespace_(), |
| 865 base::StringPrintf("Message size: %u", | 865 base::StringPrintf("Message size: %u", |
| 866 static_cast<uint32>(message_size))); | 866 static_cast<uint32>(message_size))); |
| 867 SetReadState(READ_STATE_DO_CALLBACK); | 867 SetReadState(READ_STATE_DO_CALLBACK); |
| 868 } else if (error_state_ != CHANNEL_ERROR_NONE) { | 868 } else if (error_state_ != CHANNEL_ERROR_NONE) { |
| 869 DCHECK(current_message_.get() == NULL); | 869 DCHECK(current_message_.get() == nullptr); |
| 870 SetReadState(READ_STATE_ERROR); | 870 SetReadState(READ_STATE_ERROR); |
| 871 } else { | 871 } else { |
| 872 DCHECK(current_message_.get() == NULL); | 872 DCHECK(current_message_.get() == nullptr); |
| 873 SetReadState(READ_STATE_READ); | 873 SetReadState(READ_STATE_READ); |
| 874 } | 874 } |
| 875 return net::OK; | 875 return net::OK; |
| 876 } | 876 } |
| 877 | 877 |
| 878 int CastSocket::DoReadCallback() { | 878 int CastSocket::DoReadCallback() { |
| 879 SetReadState(READ_STATE_READ); | 879 SetReadState(READ_STATE_READ); |
| 880 const CastMessage& message = *current_message_; | 880 const CastMessage& message = *current_message_; |
| 881 if (ready_state_ == READY_STATE_CONNECTING) { | 881 if (ready_state_ == READY_STATE_CONNECTING) { |
| 882 if (IsAuthMessage(message)) { | 882 if (IsAuthMessage(message)) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 message_data.size()); | 989 message_data.size()); |
| 990 return true; | 990 return true; |
| 991 } | 991 } |
| 992 | 992 |
| 993 CastSocket::WriteRequest::~WriteRequest() { } | 993 CastSocket::WriteRequest::~WriteRequest() { } |
| 994 } // namespace cast_channel | 994 } // namespace cast_channel |
| 995 } // namespace core_api | 995 } // namespace core_api |
| 996 } // namespace extensions | 996 } // namespace extensions |
| 997 | 997 |
| 998 #undef VLOG_WITH_CONNECTION | 998 #undef VLOG_WITH_CONNECTION |
| OLD | NEW |