OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/client/plugin/chromoting_instance.h" | 5 #include "remoting/client/plugin/chromoting_instance.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 case protocol::ConnectionToHost::CONNECTING: | 74 case protocol::ConnectionToHost::CONNECTING: |
75 return "CONNECTING"; | 75 return "CONNECTING"; |
76 case protocol::ConnectionToHost::CONNECTED: | 76 case protocol::ConnectionToHost::CONNECTED: |
77 return "CONNECTED"; | 77 return "CONNECTED"; |
78 case protocol::ConnectionToHost::CLOSED: | 78 case protocol::ConnectionToHost::CLOSED: |
79 return "CLOSED"; | 79 return "CLOSED"; |
80 case protocol::ConnectionToHost::FAILED: | 80 case protocol::ConnectionToHost::FAILED: |
81 return "FAILED"; | 81 return "FAILED"; |
82 } | 82 } |
83 NOTREACHED(); | 83 NOTREACHED(); |
84 return ""; | 84 return std::string(); |
85 } | 85 } |
86 | 86 |
87 // TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp | 87 // TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp |
88 // and let it handle it, but it would be hard to fix it now because | 88 // and let it handle it, but it would be hard to fix it now because |
89 // client plugin and webapp versions may not be in sync. It should be | 89 // client plugin and webapp versions may not be in sync. It should be |
90 // easy to do after we are finished moving the client plugin to NaCl. | 90 // easy to do after we are finished moving the client plugin to NaCl. |
91 std::string ConnectionErrorToString(protocol::ErrorCode error) { | 91 std::string ConnectionErrorToString(protocol::ErrorCode error) { |
92 // Values returned by this function must match the | 92 // Values returned by this function must match the |
93 // remoting.ClientSession.Error enum in JS code. | 93 // remoting.ClientSession.Error enum in JS code. |
94 switch (error) { | 94 switch (error) { |
(...skipping 13 matching lines...) Expand all Loading... |
108 case protocol::HOST_OVERLOAD: | 108 case protocol::HOST_OVERLOAD: |
109 return "HOST_OVERLOAD"; | 109 return "HOST_OVERLOAD"; |
110 | 110 |
111 case protocol::CHANNEL_CONNECTION_ERROR: | 111 case protocol::CHANNEL_CONNECTION_ERROR: |
112 case protocol::SIGNALING_ERROR: | 112 case protocol::SIGNALING_ERROR: |
113 case protocol::SIGNALING_TIMEOUT: | 113 case protocol::SIGNALING_TIMEOUT: |
114 case protocol::UNKNOWN_ERROR: | 114 case protocol::UNKNOWN_ERROR: |
115 return "NETWORK_FAILURE"; | 115 return "NETWORK_FAILURE"; |
116 } | 116 } |
117 DLOG(FATAL) << "Unknown error code" << error; | 117 DLOG(FATAL) << "Unknown error code" << error; |
118 return ""; | 118 return std::string(); |
119 } | 119 } |
120 | 120 |
121 // This flag blocks LOGs to the UI if we're already in the middle of logging | 121 // This flag blocks LOGs to the UI if we're already in the middle of logging |
122 // to the UI. This prevents a potential infinite loop if we encounter an error | 122 // to the UI. This prevents a potential infinite loop if we encounter an error |
123 // while sending the log message to the UI. | 123 // while sending the log message to the UI. |
124 bool g_logging_to_plugin = false; | 124 bool g_logging_to_plugin = false; |
125 bool g_has_logging_instance = false; | 125 bool g_has_logging_instance = false; |
126 base::LazyInstance<scoped_refptr<base::SingleThreadTaskRunner> >::Leaky | 126 base::LazyInstance<scoped_refptr<base::SingleThreadTaskRunner> >::Leaky |
127 g_logging_task_runner = LAZY_INSTANCE_INITIALIZER; | 127 g_logging_task_runner = LAZY_INSTANCE_INITIALIZER; |
128 base::LazyInstance<base::WeakPtr<ChromotingInstance> >::Leaky | 128 base::LazyInstance<base::WeakPtr<ChromotingInstance> >::Leaky |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 url_components.scheme.len); | 914 url_components.scheme.len); |
915 return url_scheme == kChromeExtensionUrlScheme; | 915 return url_scheme == kChromeExtensionUrlScheme; |
916 } | 916 } |
917 | 917 |
918 bool ChromotingInstance::IsConnected() { | 918 bool ChromotingInstance::IsConnected() { |
919 return host_connection_.get() && | 919 return host_connection_.get() && |
920 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); | 920 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); |
921 } | 921 } |
922 | 922 |
923 } // namespace remoting | 923 } // namespace remoting |
OLD | NEW |