Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: extensions/browser/api/cast_channel/cast_transport.cc

Issue 2891923004: [cast_channel] Make cast_channel related files not depend on "cast_channel.h" (Closed)
Patch Set: fix windows compile errors Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/cast_channel/cast_transport.cc
diff --git a/extensions/browser/api/cast_channel/cast_transport.cc b/extensions/browser/api/cast_channel/cast_transport.cc
index 1bfbb33693040ad77d004f4421c862ff4a952ae1..ce2ef7d4dd3d4143c5c2782caa75014a361f33b5 100644
--- a/extensions/browser/api/cast_channel/cast_transport.cc
+++ b/extensions/browser/api/cast_channel/cast_transport.cc
@@ -24,8 +24,9 @@
#include "net/base/net_errors.h"
#include "net/socket/socket.h"
-#define VLOG_WITH_CONNECTION(level) \
- VLOG(level) << "[" << ip_endpoint_.ToString() << ", auth=" << channel_auth_ \
+#define VLOG_WITH_CONNECTION(level) \
+ VLOG(level) << "[" << ip_endpoint_.ToString() << ", auth=" \
+ << ::cast_channel::ChannelAuthTypeToString(channel_auth_) \
<< "] "
namespace extensions {
@@ -41,7 +42,7 @@ CastTransportImpl::CastTransportImpl(net::Socket* socket,
socket_(socket),
write_state_(WRITE_STATE_IDLE),
read_state_(READ_STATE_READ),
- error_state_(CHANNEL_ERROR_NONE),
+ error_state_(ChannelError::NONE),
channel_id_(channel_id),
ip_endpoint_(ip_endpoint),
channel_auth_(channel_auth),
@@ -119,25 +120,25 @@ proto::WriteState CastTransportImpl::WriteStateToProto(
// static
proto::ErrorState CastTransportImpl::ErrorStateToProto(ChannelError state) {
switch (state) {
- case CHANNEL_ERROR_NONE:
+ case ChannelError::NONE:
return proto::CHANNEL_ERROR_NONE;
- case CHANNEL_ERROR_CHANNEL_NOT_OPEN:
+ case ChannelError::CHANNEL_NOT_OPEN:
return proto::CHANNEL_ERROR_CHANNEL_NOT_OPEN;
- case CHANNEL_ERROR_AUTHENTICATION_ERROR:
+ case ChannelError::AUTHENTICATION_ERROR:
return proto::CHANNEL_ERROR_AUTHENTICATION_ERROR;
- case CHANNEL_ERROR_CONNECT_ERROR:
+ case ChannelError::CONNECT_ERROR:
return proto::CHANNEL_ERROR_CONNECT_ERROR;
- case CHANNEL_ERROR_SOCKET_ERROR:
+ case ChannelError::CAST_SOCKET_ERROR:
return proto::CHANNEL_ERROR_SOCKET_ERROR;
- case CHANNEL_ERROR_TRANSPORT_ERROR:
+ case ChannelError::TRANSPORT_ERROR:
return proto::CHANNEL_ERROR_TRANSPORT_ERROR;
- case CHANNEL_ERROR_INVALID_MESSAGE:
+ case ChannelError::INVALID_MESSAGE:
return proto::CHANNEL_ERROR_INVALID_MESSAGE;
- case CHANNEL_ERROR_INVALID_CHANNEL_ID:
+ case ChannelError::INVALID_CHANNEL_ID:
return proto::CHANNEL_ERROR_INVALID_CHANNEL_ID;
- case CHANNEL_ERROR_CONNECT_TIMEOUT:
+ case ChannelError::CONNECT_TIMEOUT:
return proto::CHANNEL_ERROR_CONNECT_TIMEOUT;
- case CHANNEL_ERROR_UNKNOWN:
+ case ChannelError::UNKNOWN:
return proto::CHANNEL_ERROR_UNKNOWN;
default:
NOTREACHED();
@@ -209,7 +210,8 @@ void CastTransportImpl::SetWriteState(WriteState write_state) {
}
void CastTransportImpl::SetErrorState(ChannelError error_state) {
- VLOG_WITH_CONNECTION(2) << "SetErrorState: " << error_state;
+ VLOG_WITH_CONNECTION(2) << "SetErrorState: "
+ << ::cast_channel::ChannelErrorToString(error_state);
error_state_ = error_state;
}
@@ -250,7 +252,7 @@ void CastTransportImpl::OnWriteResult(int result) {
default:
NOTREACHED() << "Unknown state in write state machine: " << state;
SetWriteState(WRITE_STATE_ERROR);
- SetErrorState(CHANNEL_ERROR_UNKNOWN);
+ SetErrorState(ChannelError::UNKNOWN);
rv = net::ERR_FAILED;
break;
}
@@ -258,7 +260,7 @@ void CastTransportImpl::OnWriteResult(int result) {
if (write_state_ == WRITE_STATE_ERROR) {
FlushWriteQueue();
- DCHECK_NE(CHANNEL_ERROR_NONE, error_state_);
+ DCHECK_NE(ChannelError::NONE, error_state_);
VLOG_WITH_CONNECTION(2) << "Sending OnError().";
delegate_->OnError(error_state_);
}
@@ -285,7 +287,7 @@ int CastTransportImpl::DoWriteComplete(int result) {
DCHECK(!write_queue_.empty());
if (result <= 0) { // NOTE that 0 also indicates an error
logger_->LogSocketEventWithRv(channel_id_, proto::SOCKET_WRITE, result);
- SetErrorState(CHANNEL_ERROR_SOCKET_ERROR);
+ SetErrorState(ChannelError::CAST_SOCKET_ERROR);
SetWriteState(WRITE_STATE_HANDLE_ERROR);
return result == 0 ? net::ERR_FAILED : result;
}
@@ -323,7 +325,7 @@ int CastTransportImpl::DoWriteCallback() {
int CastTransportImpl::DoWriteHandleError(int result) {
VLOG_WITH_CONNECTION(2) << "DoWriteHandleError result=" << result;
- DCHECK_NE(CHANNEL_ERROR_NONE, error_state_);
+ DCHECK_NE(ChannelError::NONE, error_state_);
DCHECK_LT(result, 0);
SetWriteState(WRITE_STATE_ERROR);
return net::ERR_FAILED;
@@ -372,7 +374,7 @@ void CastTransportImpl::OnReadResult(int result) {
default:
NOTREACHED() << "Unknown state in read state machine: " << state;
SetReadState(READ_STATE_ERROR);
- SetErrorState(CHANNEL_ERROR_UNKNOWN);
+ SetErrorState(ChannelError::UNKNOWN);
rv = net::ERR_FAILED;
break;
}
@@ -404,7 +406,7 @@ int CastTransportImpl::DoReadComplete(int result) {
if (result <= 0) {
logger_->LogSocketEventWithRv(channel_id_, proto::SOCKET_READ, result);
VLOG_WITH_CONNECTION(1) << "Read error, peer closed the socket.";
- SetErrorState(CHANNEL_ERROR_SOCKET_ERROR);
+ SetErrorState(ChannelError::CAST_SOCKET_ERROR);
SetReadState(READ_STATE_HANDLE_ERROR);
return result == 0 ? net::ERR_FAILED : result;
}
@@ -413,12 +415,12 @@ int CastTransportImpl::DoReadComplete(int result) {
DCHECK(!current_message_);
ChannelError framing_error;
current_message_ = framer_->Ingest(result, &message_size, &framing_error);
- if (current_message_.get() && (framing_error == CHANNEL_ERROR_NONE)) {
+ if (current_message_.get() && (framing_error == ChannelError::NONE)) {
DCHECK_GT(message_size, static_cast<size_t>(0));
SetReadState(READ_STATE_DO_CALLBACK);
- } else if (framing_error != CHANNEL_ERROR_NONE) {
+ } else if (framing_error != ChannelError::NONE) {
DCHECK(!current_message_);
- SetErrorState(CHANNEL_ERROR_INVALID_MESSAGE);
+ SetErrorState(ChannelError::INVALID_MESSAGE);
SetReadState(READ_STATE_HANDLE_ERROR);
} else {
DCHECK(!current_message_);
@@ -431,7 +433,7 @@ int CastTransportImpl::DoReadCallback() {
VLOG_WITH_CONNECTION(2) << "DoReadCallback";
if (!IsCastMessageValid(*current_message_)) {
SetReadState(READ_STATE_HANDLE_ERROR);
- SetErrorState(CHANNEL_ERROR_INVALID_MESSAGE);
+ SetErrorState(ChannelError::INVALID_MESSAGE);
return net::ERR_INVALID_RESPONSE;
}
SetReadState(READ_STATE_READ);
@@ -442,7 +444,7 @@ int CastTransportImpl::DoReadCallback() {
int CastTransportImpl::DoReadHandleError(int result) {
VLOG_WITH_CONNECTION(2) << "DoReadHandleError";
- DCHECK_NE(CHANNEL_ERROR_NONE, error_state_);
+ DCHECK_NE(ChannelError::NONE, error_state_);
DCHECK_LE(result, 0);
SetReadState(READ_STATE_ERROR);
return net::ERR_FAILED;
« no previous file with comments | « extensions/browser/api/cast_channel/cast_transport.h ('k') | extensions/browser/api/cast_channel/cast_transport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698