Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ | 5 #ifndef REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ |
| 6 #define REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ | 6 #define REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/synchronization/cancellation_flag.h" | 14 #include "base/synchronization/cancellation_flag.h" |
| 15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
| 17 #include "remoting/host/chromoting_host_context.h" | 17 #include "remoting/host/chromoting_host_context.h" |
| 18 #include "remoting/host/host_status_observer.h" | 18 #include "remoting/host/host_status_observer.h" |
| 19 #include "remoting/host/plugin/host_plugin_logger.h" | |
| 20 #include "third_party/npapi/bindings/npapi.h" | 19 #include "third_party/npapi/bindings/npapi.h" |
| 21 #include "third_party/npapi/bindings/npfunctions.h" | 20 #include "third_party/npapi/bindings/npfunctions.h" |
| 22 #include "third_party/npapi/bindings/npruntime.h" | 21 #include "third_party/npapi/bindings/npruntime.h" |
| 23 | 22 |
| 24 class Task; | 23 class Task; |
| 25 | 24 |
| 26 namespace tracked_objects { | 25 namespace tracked_objects { |
| 27 class Location; | 26 class Location; |
| 28 } // namespace tracked_objects | 27 } // namespace tracked_objects |
| 29 | 28 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 53 bool Invoke(const std::string& method_name, | 52 bool Invoke(const std::string& method_name, |
| 54 const NPVariant* args, | 53 const NPVariant* args, |
| 55 uint32_t argCount, | 54 uint32_t argCount, |
| 56 NPVariant* result); | 55 NPVariant* result); |
| 57 bool HasProperty(const std::string& property_name); | 56 bool HasProperty(const std::string& property_name); |
| 58 bool GetProperty(const std::string& property_name, NPVariant* result); | 57 bool GetProperty(const std::string& property_name, NPVariant* result); |
| 59 bool SetProperty(const std::string& property_name, const NPVariant* value); | 58 bool SetProperty(const std::string& property_name, const NPVariant* value); |
| 60 bool RemoveProperty(const std::string& property_name); | 59 bool RemoveProperty(const std::string& property_name); |
| 61 bool Enumerate(std::vector<std::string>* values); | 60 bool Enumerate(std::vector<std::string>* values); |
| 62 | 61 |
| 63 // Call LogDebugInfo handler if there is one. | |
| 64 void LogDebugInfo(const std::string& message); | |
| 65 | |
| 66 // remoting::HostStatusObserver implementation. | 62 // remoting::HostStatusObserver implementation. |
| 67 virtual void OnSignallingConnected(remoting::SignalStrategy* signal_strategy, | 63 virtual void OnSignallingConnected(remoting::SignalStrategy* signal_strategy, |
| 68 const std::string& full_jid) OVERRIDE; | 64 const std::string& full_jid) OVERRIDE; |
| 69 virtual void OnSignallingDisconnected() OVERRIDE; | 65 virtual void OnSignallingDisconnected() OVERRIDE; |
| 70 virtual void OnAccessDenied() OVERRIDE; | 66 virtual void OnAccessDenied() OVERRIDE; |
| 71 virtual void OnAuthenticatedClientsChanged(int clients_connected) OVERRIDE; | 67 virtual void OnAuthenticatedClientsChanged(int clients_connected) OVERRIDE; |
| 72 virtual void OnShutdown() OVERRIDE; | 68 virtual void OnShutdown() OVERRIDE; |
| 73 | 69 |
| 70 static bool LogToUI(int severity, const char* file, int line, | |
|
dmac
2011/07/21 23:37:07
comment method please.
dmac
2011/07/21 23:37:07
severity is not an enum?
garykac
2011/08/02 00:15:37
defined in base/logging.h as an int.
garykac
2011/08/02 00:15:37
Done.
| |
| 71 size_t message_start, const std::string& str); | |
| 74 private: | 72 private: |
| 75 enum State { | 73 enum State { |
| 76 kDisconnected, | 74 kDisconnected, |
| 77 kRequestedAccessCode, | 75 kRequestedAccessCode, |
| 78 kReceivedAccessCode, | 76 kReceivedAccessCode, |
| 79 kConnected, | 77 kConnected, |
| 80 kAffirmingConnection, | 78 kAffirmingConnection, |
| 81 kError | 79 kError |
| 82 }; | 80 }; |
| 83 | 81 |
| 84 // Start connection. args are: | 82 // Start connection. args are: |
| 85 // string uid, string auth_token | 83 // string uid, string auth_token |
| 86 // No result. | 84 // No result. |
| 87 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result); | 85 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result); |
| 88 | 86 |
| 89 // Disconnect. No arguments or result. | 87 // Disconnect. No arguments or result. |
| 90 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result); | 88 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result); |
| 91 | 89 |
| 92 // Call OnStateChanged handler if there is one. | 90 // Call OnStateChanged handler if there is one. |
| 93 void OnStateChanged(State state); | 91 void OnStateChanged(State state); |
| 94 | 92 |
| 93 // Call LogDebugInfo handler if there is one. | |
| 94 void LogDebugInfo(const std::string& message); | |
| 95 | |
| 95 // Callbacks invoked during session setup. | 96 // Callbacks invoked during session setup. |
| 96 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, | 97 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, |
| 97 bool success, | 98 bool success, |
| 98 const std::string& support_id); | 99 const std::string& support_id); |
| 99 | 100 |
| 100 // Helper functions that run on main thread. Can be called on any | 101 // Helper functions that run on main thread. Can be called on any |
| 101 // other thread. | 102 // other thread. |
| 102 void ConnectInternal(const std::string& uid, | 103 void ConnectInternal(const std::string& uid, |
| 103 const std::string& auth_token, | 104 const std::string& auth_token, |
| 104 const std::string& auth_service); | 105 const std::string& auth_service); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 124 void SetException(const std::string& exception_string); | 125 void SetException(const std::string& exception_string); |
| 125 | 126 |
| 126 NPP plugin_; | 127 NPP plugin_; |
| 127 NPObject* parent_; | 128 NPObject* parent_; |
| 128 int state_; | 129 int state_; |
| 129 std::string access_code_; | 130 std::string access_code_; |
| 130 NPObject* log_debug_info_func_; | 131 NPObject* log_debug_info_func_; |
| 131 NPObject* on_state_changed_func_; | 132 NPObject* on_state_changed_func_; |
| 132 base::PlatformThreadId np_thread_id_; | 133 base::PlatformThreadId np_thread_id_; |
| 133 | 134 |
| 134 scoped_ptr<HostPluginLogger> logger_; | |
| 135 | |
| 136 scoped_ptr<RegisterSupportHostRequest> register_request_; | 135 scoped_ptr<RegisterSupportHostRequest> register_request_; |
| 137 scoped_refptr<ChromotingHost> host_; | 136 scoped_refptr<ChromotingHost> host_; |
| 138 scoped_refptr<MutableHostConfig> host_config_; | 137 scoped_refptr<MutableHostConfig> host_config_; |
| 139 ChromotingHostContext host_context_; | 138 ChromotingHostContext host_context_; |
| 140 int failed_login_attempts_; | 139 int failed_login_attempts_; |
| 141 | 140 |
| 142 base::WaitableEvent disconnected_event_; | 141 base::WaitableEvent disconnected_event_; |
| 143 base::CancellationFlag destructing_; | 142 base::CancellationFlag destructing_; |
| 144 }; | 143 }; |
| 145 | 144 |
| 146 } // namespace remoting | 145 } // namespace remoting |
| 147 | 146 |
| 148 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); | 147 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); |
| 149 | 148 |
| 150 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ | 149 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ |
| OLD | NEW |