Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Unified Diff: remoting/host/host_plugin.cc

Issue 7134023: Notify calling web-app when Host plugin becomes connected to a client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Stop accepting connections once there is one active in Me2Mom. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/host_plugin.cc
diff --git a/remoting/host/host_plugin.cc b/remoting/host/host_plugin.cc
index 3189634df27dffd42252858a5654a832f280d42d..954fe63bd2415ade778744671eb2fd1919603786 100644
--- a/remoting/host/host_plugin.cc
+++ b/remoting/host/host_plugin.cc
@@ -131,7 +131,7 @@ NPObject* ObjectFromNPVariant(const NPVariant& variant) {
}
// NPAPI plugin implementation for remoting host script object.
-class HostNPScriptObject {
+class HostNPScriptObject : remoting::HostStatusObserver {
public:
HostNPScriptObject(NPP plugin, NPObject* parent)
: plugin_(plugin),
@@ -352,9 +352,15 @@ class HostNPScriptObject {
void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier,
bool success,
const std::string& support_id);
- void OnConnected();
void OnHostShutdown();
+ // HostStatusObserver interface.
+ virtual void OnSignallingConnected(remoting::SignalStrategy* signal_strategy,
+ const std::string& full_jid) {}
+ virtual void OnSignallingDisconnected() {}
+ virtual void OnAuthenticatedClientsChanged(int clients_connected);
+ virtual void OnShutdown() {}
+
// Call a JavaScript function wrapped as an NPObject.
// If result is non-null, the result of the call will be stored in it.
// Caller is responsible for releasing result if they ask for it.
@@ -454,6 +460,7 @@ bool HostNPScriptObject::Connect(const NPVariant* args,
remoting::ChromotingHost::Create(&host_context_, host_config,
access_verifier.release());
host->AddStatusObserver(register_request);
+ host->AddStatusObserver(this);
host->set_me2mom(true);
// Nothing went wrong, so lets save the host, config and request.
@@ -513,14 +520,14 @@ void HostNPScriptObject::OnReceivedSupportID(
OnStateChanged(kReceivedAccessCode);
}
-void HostNPScriptObject::OnConnected() {
+void HostNPScriptObject::OnHostShutdown() {
CHECK_NE(base::PlatformThread::CurrentId(), np_thread_id_);
- OnStateChanged(kConnected);
+ OnStateChanged(kDisconnected);
}
-void HostNPScriptObject::OnHostShutdown() {
+void HostNPScriptObject::OnAuthenticatedClientsChanged(int clients_connected) {
CHECK_NE(base::PlatformThread::CurrentId(), np_thread_id_);
- OnStateChanged(kDisconnected);
+ OnStateChanged(clients_connected ? kConnected : kDisconnected);
}
void HostNPScriptObject::OnStateChanged(State state) {

Powered by Google App Engine
This is Rietveld 408576698