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 #if defined(OS_NACL) | 10 #if defined(OS_NACL) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 const int kBandwidthHistogramBuckets = 100; | 91 const int kBandwidthHistogramBuckets = 100; |
92 | 92 |
93 #if defined(USE_OPENSSL) | 93 #if defined(USE_OPENSSL) |
94 // Size of the random seed blob used to initialize RNG in libjingle. Libjingle | 94 // Size of the random seed blob used to initialize RNG in libjingle. Libjingle |
95 // uses the seed only for OpenSSL builds. OpenSSL needs at least 32 bytes of | 95 // uses the seed only for OpenSSL builds. OpenSSL needs at least 32 bytes of |
96 // entropy (see http://wiki.openssl.org/index.php/Random_Numbers), but stores | 96 // entropy (see http://wiki.openssl.org/index.php/Random_Numbers), but stores |
97 // 1039 bytes of state, so we initialize it with 1k or random data. | 97 // 1039 bytes of state, so we initialize it with 1k or random data. |
98 const int kRandomSeedSize = 1024; | 98 const int kRandomSeedSize = 1024; |
99 #endif // defined(USE_OPENSSL) | 99 #endif // defined(USE_OPENSSL) |
100 | 100 |
101 std::string ConnectionStateToString(protocol::ConnectionToHost::State state) { | |
102 // Values returned by this function must match the | |
103 // remoting.ClientSession.State enum in JS code. | |
104 switch (state) { | |
105 case protocol::ConnectionToHost::INITIALIZING: | |
106 return "INITIALIZING"; | |
107 case protocol::ConnectionToHost::CONNECTING: | |
108 return "CONNECTING"; | |
109 case protocol::ConnectionToHost::AUTHENTICATED: | |
110 return "AUTHENTICATED"; | |
111 case protocol::ConnectionToHost::CONNECTED: | |
112 return "CONNECTED"; | |
113 case protocol::ConnectionToHost::CLOSED: | |
114 return "CLOSED"; | |
115 case protocol::ConnectionToHost::FAILED: | |
116 return "FAILED"; | |
117 } | |
118 NOTREACHED(); | |
119 return std::string(); | |
120 } | |
121 | |
122 // TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp | 101 // TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp |
123 // and let it handle it, but it would be hard to fix it now because | 102 // and let it handle it, but it would be hard to fix it now because |
124 // client plugin and webapp versions may not be in sync. It should be | 103 // client plugin and webapp versions may not be in sync. It should be |
125 // easy to do after we are finished moving the client plugin to NaCl. | 104 // easy to do after we are finished moving the client plugin to NaCl. |
126 std::string ConnectionErrorToString(protocol::ErrorCode error) { | 105 std::string ConnectionErrorToString(protocol::ErrorCode error) { |
127 // Values returned by this function must match the | 106 // Values returned by this function must match the |
128 // remoting.ClientSession.Error enum in JS code. | 107 // remoting.ClientSession.Error enum in JS code. |
129 switch (error) { | 108 switch (error) { |
130 case protocol::OK: | 109 case protocol::OK: |
131 return "NONE"; | 110 return "NONE"; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 458 |
480 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 459 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
481 data->Set("rects", rects_value.release()); | 460 data->Set("rects", rects_value.release()); |
482 PostLegacyJsonMessage("onDebugRegion", data.Pass()); | 461 PostLegacyJsonMessage("onDebugRegion", data.Pass()); |
483 } | 462 } |
484 | 463 |
485 void ChromotingInstance::OnConnectionState( | 464 void ChromotingInstance::OnConnectionState( |
486 protocol::ConnectionToHost::State state, | 465 protocol::ConnectionToHost::State state, |
487 protocol::ErrorCode error) { | 466 protocol::ErrorCode error) { |
488 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 467 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
489 data->SetString("state", ConnectionStateToString(state)); | 468 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); |
490 data->SetString("error", ConnectionErrorToString(error)); | 469 data->SetString("error", ConnectionErrorToString(error)); |
491 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); | 470 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); |
492 } | 471 } |
493 | 472 |
494 void ChromotingInstance::FetchThirdPartyToken( | 473 void ChromotingInstance::FetchThirdPartyToken( |
495 const GURL& token_url, | 474 const GURL& token_url, |
496 const std::string& host_public_key, | 475 const std::string& host_public_key, |
497 const std::string& scope, | 476 const std::string& scope, |
498 base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy) { | 477 base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy) { |
499 // Once the Session object calls this function, it won't continue the | 478 // Once the Session object calls this function, it won't continue the |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 | 1211 |
1233 #if !defined(OS_NACL) | 1212 #if !defined(OS_NACL) |
1234 // Log messages are forwarded to the webapp only in PNaCl version of the | 1213 // Log messages are forwarded to the webapp only in PNaCl version of the |
1235 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl | 1214 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl |
1236 // version. | 1215 // version. |
1237 ProcessLogToUI(message); | 1216 ProcessLogToUI(message); |
1238 #endif // !defined(OS_NACL) | 1217 #endif // !defined(OS_NACL) |
1239 } | 1218 } |
1240 | 1219 |
1241 } // namespace remoting | 1220 } // namespace remoting |
OLD | NEW |