| 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 <nacl_io/nacl_io.h> | 7 #include <nacl_io/nacl_io.h> |
| 8 #include <sys/mount.h> | 8 #include <sys/mount.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 use_async_pin_dialog_(false), | 164 use_async_pin_dialog_(false), |
| 165 weak_factory_(this) { | 165 weak_factory_(this) { |
| 166 // In NaCl global resources need to be initialized differently because they | 166 // In NaCl global resources need to be initialized differently because they |
| 167 // are not shared with Chrome. | 167 // are not shared with Chrome. |
| 168 thread_task_runner_handle_.reset( | 168 thread_task_runner_handle_.reset( |
| 169 new base::ThreadTaskRunnerHandle(plugin_task_runner_)); | 169 new base::ThreadTaskRunnerHandle(plugin_task_runner_)); |
| 170 thread_wrapper_ = | 170 thread_wrapper_ = |
| 171 jingle_glue::JingleThreadWrapper::WrapTaskRunner(plugin_task_runner_); | 171 jingle_glue::JingleThreadWrapper::WrapTaskRunner(plugin_task_runner_); |
| 172 | 172 |
| 173 // Register a global log handler. | 173 // Register a global log handler. |
| 174 ChromotingInstance::RegisterLogMessageHandler(); | 174 ChromotingInstance::RegisterLogMessageListener(); |
| 175 | 175 |
| 176 nacl_io_init_ppapi(pp_instance, pp::Module::Get()->get_browser_interface()); | 176 nacl_io_init_ppapi(pp_instance, pp::Module::Get()->get_browser_interface()); |
| 177 mount("", "/etc", "memfs", 0, ""); | 177 mount("", "/etc", "memfs", 0, ""); |
| 178 mount("", "/usr", "memfs", 0, ""); | 178 mount("", "/usr", "memfs", 0, ""); |
| 179 | 179 |
| 180 // Register for mouse, wheel and keyboard events. | 180 // Register for mouse, wheel and keyboard events. |
| 181 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL); | 181 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL); |
| 182 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); | 182 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); |
| 183 | 183 |
| 184 // Disable the client-side IME in Chrome. | 184 // Disable the client-side IME in Chrome. |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 data->SetDouble("decodeLatency", perf_tracker_.video_decode_ms().Average()); | 1030 data->SetDouble("decodeLatency", perf_tracker_.video_decode_ms().Average()); |
| 1031 data->SetDouble("maxDecodeLatency", perf_tracker_.video_decode_ms().Max()); | 1031 data->SetDouble("maxDecodeLatency", perf_tracker_.video_decode_ms().Max()); |
| 1032 data->SetDouble("renderLatency", perf_tracker_.video_paint_ms().Average()); | 1032 data->SetDouble("renderLatency", perf_tracker_.video_paint_ms().Average()); |
| 1033 data->SetDouble("maxRenderLatency", perf_tracker_.video_paint_ms().Max()); | 1033 data->SetDouble("maxRenderLatency", perf_tracker_.video_paint_ms().Max()); |
| 1034 data->SetDouble("roundtripLatency", perf_tracker_.round_trip_ms().Average()); | 1034 data->SetDouble("roundtripLatency", perf_tracker_.round_trip_ms().Average()); |
| 1035 data->SetDouble("maxRoundtripLatency", perf_tracker_.round_trip_ms().Max()); | 1035 data->SetDouble("maxRoundtripLatency", perf_tracker_.round_trip_ms().Max()); |
| 1036 PostLegacyJsonMessage("onPerfStats", std::move(data)); | 1036 PostLegacyJsonMessage("onPerfStats", std::move(data)); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 // static | 1039 // static |
| 1040 void ChromotingInstance::RegisterLogMessageHandler() { | 1040 void ChromotingInstance::RegisterLogMessageListener() { |
| 1041 base::AutoLock lock(g_logging_lock.Get()); | 1041 base::AutoLock lock(g_logging_lock.Get()); |
| 1042 | 1042 |
| 1043 // Set up log message handler. | 1043 // Set up log message handler. |
| 1044 // This is not thread-safe so we need it within our lock. | 1044 // This is not thread-safe so we need it within our lock. |
| 1045 logging::SetLogMessageHandler(&LogToUI); | 1045 logging::AddLogMessageListener(LogToUI); |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 void ChromotingInstance::RegisterLoggingInstance() { | 1048 void ChromotingInstance::RegisterLoggingInstance() { |
| 1049 base::AutoLock lock(g_logging_lock.Get()); | 1049 base::AutoLock lock(g_logging_lock.Get()); |
| 1050 g_logging_instance = pp_instance(); | 1050 g_logging_instance = pp_instance(); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 void ChromotingInstance::UnregisterLoggingInstance() { | 1053 void ChromotingInstance::UnregisterLoggingInstance() { |
| 1054 base::AutoLock lock(g_logging_lock.Get()); | 1054 base::AutoLock lock(g_logging_lock.Get()); |
| 1055 | 1055 |
| 1056 // Don't unregister unless we're the currently registered instance. | 1056 // Don't unregister unless we're the currently registered instance. |
| 1057 if (pp_instance() != g_logging_instance) | 1057 if (pp_instance() != g_logging_instance) |
| 1058 return; | 1058 return; |
| 1059 | 1059 |
| 1060 // Unregister this instance for logging. | 1060 // Unregister this instance for logging. |
| 1061 g_logging_instance = 0; | 1061 g_logging_instance = 0; |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 // static | 1064 // static |
| 1065 bool ChromotingInstance::LogToUI(int severity, const char* file, int line, | 1065 void ChromotingInstance::LogToUI(int severity, const char* file, int line, |
| 1066 size_t message_start, | 1066 size_t message_start, |
| 1067 const std::string& str) { | 1067 const std::string& str) { |
| 1068 PP_LogLevel log_level = PP_LOGLEVEL_ERROR; | 1068 PP_LogLevel log_level = PP_LOGLEVEL_ERROR; |
| 1069 switch (severity) { | 1069 switch (severity) { |
| 1070 case logging::LOG_INFO: | 1070 case logging::LOG_INFO: |
| 1071 log_level = PP_LOGLEVEL_TIP; | 1071 log_level = PP_LOGLEVEL_TIP; |
| 1072 break; | 1072 break; |
| 1073 case logging::LOG_WARNING: | 1073 case logging::LOG_WARNING: |
| 1074 log_level = PP_LOGLEVEL_WARNING; | 1074 log_level = PP_LOGLEVEL_WARNING; |
| 1075 break; | 1075 break; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1090 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); | 1090 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); |
| 1091 if (console) | 1091 if (console) |
| 1092 console->Log(pp_instance, log_level, pp::Var(str).pp_var()); | 1092 console->Log(pp_instance, log_level, pp::Var(str).pp_var()); |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 // If this is a fatal message the log handler is going to crash after this | 1095 // If this is a fatal message the log handler is going to crash after this |
| 1096 // function returns. In that case sleep for 1 second, Otherwise the plugin | 1096 // function returns. In that case sleep for 1 second, Otherwise the plugin |
| 1097 // may crash before the message is delivered to the console. | 1097 // may crash before the message is delivered to the console. |
| 1098 if (severity == logging::LOG_FATAL) | 1098 if (severity == logging::LOG_FATAL) |
| 1099 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 1099 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
| 1100 | |
| 1101 return false; | |
| 1102 } | 1100 } |
| 1103 | 1101 |
| 1104 bool ChromotingInstance::IsConnected() { | 1102 bool ChromotingInstance::IsConnected() { |
| 1105 return client_ && | 1103 return client_ && |
| 1106 (client_->connection_state() == protocol::ConnectionToHost::CONNECTED); | 1104 (client_->connection_state() == protocol::ConnectionToHost::CONNECTED); |
| 1107 } | 1105 } |
| 1108 | 1106 |
| 1109 void ChromotingInstance::UpdateUmaEnumHistogram( | 1107 void ChromotingInstance::UpdateUmaEnumHistogram( |
| 1110 const std::string& histogram_name, | 1108 const std::string& histogram_name, |
| 1111 int64_t value, | 1109 int64_t value, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1126 if (is_custom_counts_histogram) { | 1124 if (is_custom_counts_histogram) { |
| 1127 uma.HistogramCustomCounts(histogram_name, value, histogram_min, | 1125 uma.HistogramCustomCounts(histogram_name, value, histogram_min, |
| 1128 histogram_max, histogram_buckets); | 1126 histogram_max, histogram_buckets); |
| 1129 } else { | 1127 } else { |
| 1130 uma.HistogramCustomTimes(histogram_name, value, histogram_min, | 1128 uma.HistogramCustomTimes(histogram_name, value, histogram_min, |
| 1131 histogram_max, histogram_buckets); | 1129 histogram_max, histogram_buckets); |
| 1132 } | 1130 } |
| 1133 } | 1131 } |
| 1134 | 1132 |
| 1135 } // namespace remoting | 1133 } // namespace remoting |
| OLD | NEW |