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/logger_util.h" | 5 #include "extensions/browser/api/cast_channel/logger_util.h" |
| 6 #include "extensions/common/api/cast_channel/logging.pb.h" |
6 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
7 | 8 |
8 namespace extensions { | 9 namespace extensions { |
9 namespace core_api { | 10 namespace core_api { |
10 namespace cast_channel { | 11 namespace cast_channel { |
11 | |
12 LastErrors::LastErrors() | 12 LastErrors::LastErrors() |
13 : event_type(proto::EVENT_TYPE_UNKNOWN), | 13 : event_type(proto::EVENT_TYPE_UNKNOWN), |
14 challenge_reply_error_type(proto::CHALLENGE_REPLY_ERROR_NONE), | 14 challenge_reply_error_type(proto::CHALLENGE_REPLY_ERROR_NONE), |
15 net_return_value(net::OK), | 15 net_return_value(net::OK), |
16 nss_error_code(0) { | 16 nss_error_code(0) { |
17 } | 17 } |
18 | 18 |
19 LastErrors::~LastErrors() { | 19 LastErrors::~LastErrors() { |
20 } | 20 } |
21 | 21 |
| 22 proto::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 |
| 50 proto::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 } |
22 } // namespace cast_channel | 67 } // namespace cast_channel |
23 } // namespace api | 68 } // namespace api |
24 } // namespace extensions | 69 } // namespace extensions |
OLD | NEW |