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 3 // found in the LICENSE file. 4 5 #include "extensions/browser/api/cast_channel/logger_util.h" 6 #include "extensions/common/api/cast_channel/logging.pb.h" 7 #include "net/base/net_errors.h" 8 9 namespace extensions { 10 namespace core_api { 11 namespace cast_channel { LastErrors()12LastErrors::LastErrors() 13 : event_type(proto::EVENT_TYPE_UNKNOWN), 14 challenge_reply_error_type(proto::CHALLENGE_REPLY_ERROR_NONE), 15 net_return_value(net::OK), 16 nss_error_code(0) { 17 } 18 ~LastErrors()19LastErrors::~LastErrors() { 20 } 21 ErrorStateToProto(ChannelError state)22proto::ErrorState ErrorStateToProto(ChannelError state) { 23 switch (state) { 24 case CHANNEL_ERROR_NONE: 25 return proto::CHANNEL_ERROR_NONE; 26 case CHANNEL_ERROR_CHANNEL_NOT_OPEN: 27 return proto::CHANNEL_ERROR_CHANNEL_NOT_OPEN; 28 case CHANNEL_ERROR_AUTHENTICATION_ERROR: 29 return proto::CHANNEL_ERROR_AUTHENTICATION_ERROR; 30 case CHANNEL_ERROR_CONNECT_ERROR: 31 return proto::CHANNEL_ERROR_CONNECT_ERROR; 32 case CHANNEL_ERROR_SOCKET_ERROR: 33 return proto::CHANNEL_ERROR_SOCKET_ERROR; 34 case CHANNEL_ERROR_TRANSPORT_ERROR: 35 return proto::CHANNEL_ERROR_TRANSPORT_ERROR; 36 case CHANNEL_ERROR_INVALID_MESSAGE: 37 return proto::CHANNEL_ERROR_INVALID_MESSAGE; 38 case CHANNEL_ERROR_INVALID_CHANNEL_ID: 39 return proto::CHANNEL_ERROR_INVALID_CHANNEL_ID; 40 case CHANNEL_ERROR_CONNECT_TIMEOUT: 41 return proto::CHANNEL_ERROR_CONNECT_TIMEOUT; 42 case CHANNEL_ERROR_UNKNOWN: 43 return proto::CHANNEL_ERROR_UNKNOWN; 44 default: 45 NOTREACHED(); 46 return proto::CHANNEL_ERROR_NONE; 47 } 48 } 49 ReadyStateToProto(ReadyState state)50proto::ReadyState ReadyStateToProto(ReadyState state) { 51 switch (state) { 52 case READY_STATE_NONE: 53 return proto::READY_STATE_NONE; 54 case READY_STATE_CONNECTING: 55 return proto::READY_STATE_CONNECTING; 56 case READY_STATE_OPEN: 57 return proto::READY_STATE_OPEN; 58 case READY_STATE_CLOSING: 59 return proto::READY_STATE_CLOSING; 60 case READY_STATE_CLOSED: 61 return proto::READY_STATE_CLOSED; 62 default: 63 NOTREACHED(); 64 return proto::READY_STATE_NONE; 65 } 66 } 67 } // namespace cast_channel 68 } // namespace api 69 } // namespace extensions 70