nsresult TCPSocketParent::OfflineNotification(nsISupports *aSubject) { nsCOMPtr<nsIAppOfflineInfo> info(do_QueryInterface(aSubject)); if (!info) { return NS_OK; } uint32_t targetAppId = nsIScriptSecurityManager::UNKNOWN_APP_ID; info->GetAppId(&targetAppId); // Obtain App ID uint32_t appId = GetAppId(); if (appId != targetAppId) { return NS_OK; } // If the app is offline, close the socket if (mSocket && NS_IsAppOffline(appId)) { mSocket->Close(); mSocket = nullptr; mIntermediaryObj = nullptr; mIntermediary = nullptr; } return NS_OK; }
bool TCPSocketParent::RecvOpen(const nsString& aHost, const uint16_t& aPort, const bool& aUseSSL, const bool& aUseArrayBuffers) { // We don't have browser actors in xpcshell, and hence can't run automated // tests without this loophole. if (net::UsingNeckoIPCSecurity() && !AssertAppProcessPermission(Manager()->Manager(), "tcp-socket")) { FireInteralError(this, __LINE__); return true; } // Obtain App ID uint32_t appId = GetAppId(); bool inIsolatedMozBrowser = GetInIsolatedMozBrowser(); if (NS_IsAppOffline(appId)) { NS_ERROR("Can't open socket because app is offline"); FireInteralError(this, __LINE__); return true; } mSocket = new TCPSocket(nullptr, aHost, aPort, aUseSSL, aUseArrayBuffers); mSocket->SetAppIdAndBrowser(appId, inIsolatedMozBrowser); mSocket->SetSocketBridgeParent(this); NS_ENSURE_SUCCESS(mSocket->Init(), true); return true; }
bool System::Init( ) { if( GetAppId( ) ) { LaunchExplorer( ); if( OpenAppById( ) ) { m_hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, m_ulProcessId ); return true; } } return false; }
bool TCPServerSocketParent::Init(PNeckoParent* neckoParent, const uint16_t& aLocalPort, const uint16_t& aBacklog, const nsString& aBinaryType) { mNeckoParent = neckoParent; nsresult rv; mIntermediary = do_CreateInstance("@mozilla.org/tcp-socket-intermediary;1", &rv); if (NS_FAILED(rv)) { FireInteralError(this, __LINE__); return true; } rv = mIntermediary->Listen(this, aLocalPort, aBacklog, aBinaryType, GetAppId(), getter_AddRefs(mServerSocket)); if (NS_FAILED(rv) || !mServerSocket) { FireInteralError(this, __LINE__); return true; } return true; }
bool TCPSocketParent::RecvOpen(const nsString& aHost, const uint16_t& aPort, const bool& aUseSSL, const nsString& aBinaryType) { // We don't have browser actors in xpcshell, and hence can't run automated // tests without this loophole. if (net::UsingNeckoIPCSecurity() && !AssertAppProcessPermission(Manager()->Manager(), "tcp-socket")) { FireInteralError(this, __LINE__); return true; } // Obtain App ID uint32_t appId = GetAppId(); bool inBrowser = GetInBrowser(); if (NS_IsAppOffline(appId)) { NS_ERROR("Can't open socket because app is offline"); FireInteralError(this, __LINE__); return true; } nsresult rv; mIntermediary = do_CreateInstance("@mozilla.org/tcp-socket-intermediary;1", &rv); if (NS_FAILED(rv)) { FireInteralError(this, __LINE__); return true; } rv = mIntermediary->Open(this, aHost, aPort, aUseSSL, aBinaryType, appId, inBrowser, getter_AddRefs(mSocket)); if (NS_FAILED(rv) || !mSocket) { FireInteralError(this, __LINE__); return true; } return true; }