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.
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"
11 namespace cast_channel
{
12 LastErrors::LastErrors()
13 : event_type(proto::EVENT_TYPE_UNKNOWN
),
14 challenge_reply_error_type(proto::CHALLENGE_REPLY_ERROR_NONE
),
15 net_return_value(net::OK
),
19 LastErrors::~LastErrors() {
22 proto::ErrorState
ErrorStateToProto(ChannelError 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
;
46 return proto::CHANNEL_ERROR_NONE
;
50 proto::ReadyState
ReadyStateToProto(ReadyState 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
;
64 return proto::READY_STATE_NONE
;
67 } // namespace cast_channel
69 } // namespace extensions