Bug 1228266 - rename TCPPresentationServer to PresentationControlService. r=junior.

MozReview-Commit-ID: 2kHZ0XUG2ew

--HG--
rename : dom/presentation/interfaces/nsITCPPresentationServer.idl => dom/presentation/interfaces/nsIPresentationControlService.idl
rename : dom/presentation/provider/TCPPresentationServer.js => dom/presentation/provider/PresentationControlService.js
extra : rebase_source : adc621d185c91e74c1abbef8cc2d519f5bbaed3a
This commit is contained in:
Shih-Chiang Chien 2016-05-20 14:53:30 +08:00
Родитель 8cddc84662
Коммит c6b56100ad
14 изменённых файлов: 115 добавлений и 115 удалений

Просмотреть файл

@ -414,7 +414,7 @@
@RESPATH@/components/PresentationDeviceInfoManager.manifest
@RESPATH@/components/PresentationDeviceInfoManager.js
@RESPATH@/components/BuiltinProviders.manifest
@RESPATH@/components/TCPPresentationServer.js
@RESPATH@/components/PresentationControlService.js
@RESPATH@/components/PresentationDataChannelSessionTransport.js
@RESPATH@/components/PresentationDataChannelSessionTransport.manifest

Просмотреть файл

@ -569,7 +569,7 @@
@RESPATH@/components/PresentationDeviceInfoManager.manifest
@RESPATH@/components/PresentationDeviceInfoManager.js
@RESPATH@/components/BuiltinProviders.manifest
@RESPATH@/components/TCPPresentationServer.js
@RESPATH@/components/PresentationControlService.js
@RESPATH@/components/PresentationDataChannelSessionTransport.js
@RESPATH@/components/PresentationDataChannelSessionTransport.manifest

Просмотреть файл

@ -6,6 +6,7 @@
XPIDL_SOURCES += [
'nsIPresentationControlChannel.idl',
'nsIPresentationControlService.idl',
'nsIPresentationDevice.idl',
'nsIPresentationDeviceManager.idl',
'nsIPresentationDevicePrompt.idl',
@ -17,7 +18,6 @@ XPIDL_SOURCES += [
'nsIPresentationSessionRequest.idl',
'nsIPresentationSessionTransport.idl',
'nsIPresentationSessionTransportBuilder.idl',
'nsITCPPresentationServer.idl',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':

Просмотреть файл

@ -7,12 +7,12 @@
interface nsIPresentationControlChannel;
%{C++
#define TCP_PRESENTATION_SERVER_CONTACT_ID \
"@mozilla.org/presentation-device/tcp-presentation-server;1"
#define PRESENTATION_CONTROL_SERVICE_CONTACT_ID \
"@mozilla.org/presentation/control-service;1"
%}
/*
* The device information required for establishing TCP control channel.
* The device information required for establishing control channel.
*/
[scriptable, uuid(296fd171-e4d0-4de0-99ff-ad8ed52ddef3)]
interface nsITCPDeviceInfo: nsISupports
@ -23,7 +23,7 @@ interface nsITCPDeviceInfo: nsISupports
};
[scriptable, uuid(09bddfaf-fcc2-4dc9-b33e-a509a1c2fb6d)]
interface nsITCPPresentationServerListener: nsISupports
interface nsIPresentationControlServerListener: nsISupports
{
/**
* Callback while the server socket changes port.
@ -48,10 +48,11 @@ interface nsITCPPresentationServerListener: nsISupports
};
/**
* TCP presentation server which can be used by discovery services.
* Presentation control service which can be used for both presentation
* control client and server.
*/
[scriptable, uuid(55d6b605-2389-4aae-a8fe-60d4440540ea)]
interface nsITCPPresentationServer: nsISupports
interface nsIPresentationControlService: nsISupports
{
/**
* This method initialize server socket.
@ -61,10 +62,10 @@ interface nsITCPPresentationServer: nsISupports
* @throws NS_ERROR_FAILURE if the server socket has been inited or the
* server socket can not be inited.
*/
void startService([optional] in uint16_t aPort);
void startServer([optional] in uint16_t aPort);
/**
* Request session to designated remote TCP device.
* Request session to designated remote presentation control receiver.
* @param aDeviceInfo
* The remtoe device info for establish connection.
* @param aUrl
@ -96,7 +97,7 @@ interface nsITCPPresentationServer: nsISupports
attribute AUTF8String id;
/**
* the listener for handling events of this TCP presentation server
* the listener for handling events of this presentation control server
*/
attribute nsITCPPresentationServerListener listener;
attribute nsIPresentationControlServerListener listener;
};

Просмотреть файл

@ -1,2 +1,2 @@
component {f4079b8b-ede5-4b90-a112-5b415a931deb} TCPPresentationServer.js
contract @mozilla.org/presentation-device/tcp-presentation-server;1 {f4079b8b-ede5-4b90-a112-5b415a931deb}
component {f4079b8b-ede5-4b90-a112-5b415a931deb} PresentationControlService.js
contract @mozilla.org/presentation/control-service;1 {f4079b8b-ede5-4b90-a112-5b415a931deb}

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/unused.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
#include "nsITCPPresentationServer.h"
#include "nsIWindowWatcher.h"
#include "nsNetUtil.h"
#include "nsPIDOMWindow.h"
@ -35,11 +34,11 @@ namespace presentation {
* This wrapper is used to break circular-reference problem.
*/
class DisplayDeviceProviderWrappedListener final
: public nsITCPPresentationServerListener
: public nsIPresentationControlServerListener
{
public:
NS_DECL_ISUPPORTS
NS_FORWARD_SAFE_NSITCPPRESENTATIONSERVERLISTENER(mListener)
NS_FORWARD_SAFE_NSIPRESENTATIONCONTROLSERVERLISTENER(mListener)
explicit DisplayDeviceProviderWrappedListener() = default;
@ -56,7 +55,7 @@ private:
};
NS_IMPL_ISUPPORTS(DisplayDeviceProviderWrappedListener,
nsITCPPresentationServerListener)
nsIPresentationControlServerListener)
NS_IMPL_ISUPPORTS(DisplayDeviceProvider::HDMIDisplayDevice,
nsIPresentationDevice,
@ -181,7 +180,7 @@ DisplayDeviceProvider::HDMIDisplayDevice::CloseTopLevelWindow()
NS_IMPL_ISUPPORTS(DisplayDeviceProvider,
nsIObserver,
nsIPresentationDeviceProvider,
nsITCPPresentationServerListener)
nsIPresentationControlServerListener)
DisplayDeviceProvider::~DisplayDeviceProvider()
{
@ -211,8 +210,8 @@ DisplayDeviceProvider::Init()
return rv;
}
mPresentationServer = do_CreateInstance(TCP_PRESENTATION_SERVER_CONTACT_ID,
&rv);
mPresentationService = do_CreateInstance(PRESENTATION_CONTROL_SERVICE_CONTACT_ID,
&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -253,13 +252,13 @@ DisplayDeviceProvider::StartTCPService()
MOZ_ASSERT(NS_IsMainThread());
nsresult rv;
rv = mPresentationServer->SetId(NS_LITERAL_CSTRING("DisplayDeviceProvider"));
rv = mPresentationService->SetId(NS_LITERAL_CSTRING("DisplayDeviceProvider"));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
uint16_t servicePort;
rv = mPresentationServer->GetPort(&servicePort);
rv = mPresentationService->GetPort(&servicePort);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -269,17 +268,17 @@ DisplayDeviceProvider::StartTCPService()
* Otherwise, we should make it start serving.
*/
if (!servicePort) {
rv = mPresentationServer->SetListener(mWrappedListener);
rv = mPresentationService->SetListener(mWrappedListener);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = mPresentationServer->StartService(0);
rv = mPresentationService->StartServer(0);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = mPresentationServer->GetPort(&servicePort);
rv = mPresentationService->GetPort(&servicePort);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -368,7 +367,7 @@ DisplayDeviceProvider::ForceDiscovery()
return NS_OK;
}
// nsITCPPresentationServerListener
// nsIPresentationControlServerListener
NS_IMETHODIMP
DisplayDeviceProvider::OnPortChange(uint16_t aPort)
{
@ -443,7 +442,7 @@ DisplayDeviceProvider::RequestSession(HDMIDisplayDevice* aDevice,
nsIPresentationControlChannel** aControlChannel)
{
MOZ_ASSERT(aDevice);
MOZ_ASSERT(mPresentationServer);
MOZ_ASSERT(mPresentationService);
NS_ENSURE_ARG_POINTER(aControlChannel);
*aControlChannel = nullptr;
@ -451,10 +450,10 @@ DisplayDeviceProvider::RequestSession(HDMIDisplayDevice* aDevice,
aDevice->Address(),
mPort);
return mPresentationServer->RequestSession(deviceInfo,
aUrl,
aPresentationId,
aControlChannel);
return mPresentationService->RequestSession(deviceInfo,
aUrl,
aPresentationId,
aControlChannel);
}
} // namespace presentation

Просмотреть файл

@ -15,7 +15,7 @@
#include "nsIObserver.h"
#include "nsIPresentationDeviceProvider.h"
#include "nsIPresentationLocalDevice.h"
#include "nsITCPPresentationServer.h"
#include "nsIPresentationControlService.h"
#include "nsIWindowWatcher.h"
#include "nsString.h"
#include "nsTArray.h"
@ -38,7 +38,7 @@ class DisplayDeviceProviderWrappedListener;
class DisplayDeviceProvider final : public nsIObserver
, public nsIPresentationDeviceProvider
, public nsITCPPresentationServerListener
, public nsIPresentationControlServerListener
, public SupportsWeakPtr<DisplayDeviceProvider>
{
private:
@ -89,7 +89,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_NSIPRESENTATIONDEVICEPROVIDER
NS_DECL_NSITCPPRESENTATIONSERVERLISTENER
NS_DECL_NSIPRESENTATIONCONTROLSERVERLISTENER
// For using WeakPtr when MOZ_REFCOUNTED_LEAK_CHECKING defined
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(DisplayDeviceProvider)
@ -114,7 +114,7 @@ private:
// PresentationDeviceManager (mDeviceListener) hold strong pointer to
// DisplayDeviceProvider. Use nsWeakPtr to avoid reference cycle.
nsWeakPtr mDeviceListener = nullptr;
nsCOMPtr<nsITCPPresentationServer> mPresentationServer;
nsCOMPtr<nsIPresentationControlService> mPresentationService;
// Used to prevent reference cycle between DisplayDeviceProvider and
// TCPPresentationServer.
RefPtr<DisplayDeviceProviderWrappedListener> mWrappedListener;

Просмотреть файл

@ -69,14 +69,14 @@ class DNSServiceWrappedListener final
: public nsIDNSServiceDiscoveryListener
, public nsIDNSRegistrationListener
, public nsIDNSServiceResolveListener
, public nsITCPPresentationServerListener
, public nsIPresentationControlServerListener
{
public:
NS_DECL_ISUPPORTS
NS_FORWARD_SAFE_NSIDNSSERVICEDISCOVERYLISTENER(mListener)
NS_FORWARD_SAFE_NSIDNSREGISTRATIONLISTENER(mListener)
NS_FORWARD_SAFE_NSIDNSSERVICERESOLVELISTENER(mListener)
NS_FORWARD_SAFE_NSITCPPRESENTATIONSERVERLISTENER(mListener)
NS_FORWARD_SAFE_NSIPRESENTATIONCONTROLSERVERLISTENER(mListener)
explicit DNSServiceWrappedListener() = default;
@ -96,14 +96,14 @@ NS_IMPL_ISUPPORTS(DNSServiceWrappedListener,
nsIDNSServiceDiscoveryListener,
nsIDNSRegistrationListener,
nsIDNSServiceResolveListener,
nsITCPPresentationServerListener)
nsIPresentationControlServerListener)
NS_IMPL_ISUPPORTS(MulticastDNSDeviceProvider,
nsIPresentationDeviceProvider,
nsIDNSServiceDiscoveryListener,
nsIDNSRegistrationListener,
nsIDNSServiceResolveListener,
nsITCPPresentationServerListener,
nsIPresentationControlServerListener,
nsIObserver)
MulticastDNSDeviceProvider::~MulticastDNSDeviceProvider()
@ -132,7 +132,7 @@ MulticastDNSDeviceProvider::Init()
return rv;
}
mPresentationServer = do_CreateInstance(TCP_PRESENTATION_SERVER_CONTACT_ID, &rv);
mPresentationService = do_CreateInstance(PRESENTATION_CONTROL_SERVICE_CONTACT_ID, &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -157,7 +157,7 @@ MulticastDNSDeviceProvider::Init()
}
#endif // MOZ_WIDGET_ANDROID
Unused << mPresentationServer->SetId(mServiceName);
Unused << mPresentationService->SetId(mServiceName);
if (mDiscoveryEnabled && NS_WARN_IF(NS_FAILED(rv = ForceDiscovery()))) {
return rv;
@ -211,7 +211,7 @@ MulticastDNSDeviceProvider::RegisterService()
nsresult rv;
uint16_t servicePort;
if (NS_WARN_IF(NS_FAILED(rv = mPresentationServer->GetPort(&servicePort)))) {
if (NS_WARN_IF(NS_FAILED(rv = mPresentationService->GetPort(&servicePort)))) {
return rv;
}
@ -220,13 +220,13 @@ MulticastDNSDeviceProvider::RegisterService()
* Otherwise, we should make it start serving.
*/
if (!servicePort) {
if (NS_WARN_IF(NS_FAILED(rv = mPresentationServer->SetListener(mWrappedListener)))) {
if (NS_WARN_IF(NS_FAILED(rv = mPresentationService->SetListener(mWrappedListener)))) {
return rv;
}
if (NS_WARN_IF(NS_FAILED(rv = mPresentationServer->StartService(0)))) {
if (NS_WARN_IF(NS_FAILED(rv = mPresentationService->StartServer(0)))) {
return rv;
}
if (NS_WARN_IF(NS_FAILED(rv = mPresentationServer->GetPort(&servicePort)))) {
if (NS_WARN_IF(NS_FAILED(rv = mPresentationService->GetPort(&servicePort)))) {
return rv;
}
}
@ -271,9 +271,9 @@ MulticastDNSDeviceProvider::UnregisterService(nsresult aReason)
mRegisterRequest = nullptr;
}
if (mPresentationServer) {
mPresentationServer->SetListener(nullptr);
mPresentationServer->Close();
if (mPresentationService) {
mPresentationService->SetListener(nullptr);
mPresentationService->Close();
}
return NS_OK;
@ -304,13 +304,13 @@ MulticastDNSDeviceProvider::RequestSession(Device* aDevice,
nsIPresentationControlChannel** aRetVal)
{
MOZ_ASSERT(aDevice);
MOZ_ASSERT(mPresentationServer);
MOZ_ASSERT(mPresentationService);
RefPtr<TCPDeviceInfo> deviceInfo = new TCPDeviceInfo(aDevice->Id(),
aDevice->Address(),
aDevice->Port());
return mPresentationServer->RequestSession(deviceInfo, aUrl, aPresentationId, aRetVal);
return mPresentationService->RequestSession(deviceInfo, aUrl, aPresentationId, aRetVal);
}
nsresult
@ -321,7 +321,7 @@ MulticastDNSDeviceProvider::AddDevice(const nsACString& aId,
const uint16_t aPort)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mPresentationServer);
MOZ_ASSERT(mPresentationService);
RefPtr<Device> device = new Device(aId, /* ID */
aServiceName,
@ -349,7 +349,7 @@ MulticastDNSDeviceProvider::UpdateDevice(const uint32_t aIndex,
const uint16_t aPort)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mPresentationServer);
MOZ_ASSERT(mPresentationService);
if (NS_WARN_IF(aIndex >= mDevices.Length())) {
return NS_ERROR_INVALID_ARG;
@ -371,7 +371,7 @@ nsresult
MulticastDNSDeviceProvider::RemoveDevice(const uint32_t aIndex)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mPresentationServer);
MOZ_ASSERT(mPresentationService);
if (NS_WARN_IF(aIndex >= mDevices.Length())) {
return NS_ERROR_INVALID_ARG;
@ -764,7 +764,7 @@ MulticastDNSDeviceProvider::OnServiceResolved(nsIDNSServiceInfo* aServiceInfo)
if (mRegisteredName == serviceName) {
LOG_I("ignore self");
if (NS_WARN_IF(NS_FAILED(rv = mPresentationServer->SetId(host)))) {
if (NS_WARN_IF(NS_FAILED(rv = mPresentationService->SetId(host)))) {
return rv;
}
@ -814,7 +814,7 @@ MulticastDNSDeviceProvider::OnResolveFailed(nsIDNSServiceInfo* aServiceInfo,
return NS_OK;
}
// nsITCPPresentationServerListener
// nsIPresentationControlServerListener
NS_IMETHODIMP
MulticastDNSDeviceProvider::OnPortChange(uint16_t aPort)
{

Просмотреть файл

@ -13,7 +13,7 @@
#include "nsIObserver.h"
#include "nsIPresentationDevice.h"
#include "nsIPresentationDeviceProvider.h"
#include "nsITCPPresentationServer.h"
#include "nsIPresentationControlService.h"
#include "nsITimer.h"
#include "nsString.h"
#include "nsTArray.h"
@ -31,7 +31,7 @@ class MulticastDNSDeviceProvider final
, public nsIDNSServiceDiscoveryListener
, public nsIDNSRegistrationListener
, public nsIDNSServiceResolveListener
, public nsITCPPresentationServerListener
, public nsIPresentationControlServerListener
, public nsIObserver
{
public:
@ -40,7 +40,7 @@ public:
NS_DECL_NSIDNSSERVICEDISCOVERYLISTENER
NS_DECL_NSIDNSREGISTRATIONLISTENER
NS_DECL_NSIDNSSERVICERESOLVELISTENER
NS_DECL_NSITCPPRESENTATIONSERVERLISTENER
NS_DECL_NSIPRESENTATIONCONTROLSERVERLISTENER
NS_DECL_NSIOBSERVER
explicit MulticastDNSDeviceProvider() = default;
@ -175,7 +175,7 @@ private:
bool mInitialized = false;
nsWeakPtr mDeviceListener;
nsCOMPtr<nsITCPPresentationServer> mPresentationServer;
nsCOMPtr<nsIPresentationControlService> mPresentationService;
nsCOMPtr<nsIDNSServiceDiscovery> mMulticastDNS;
RefPtr<DNSServiceWrappedListener> mWrappedListener;

Просмотреть файл

@ -11,7 +11,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
const DEBUG = Services.prefs.getBoolPref("dom.presentation.tcp_server.debug");
function log(aMsg) {
dump("-*- TCPPresentationServer.js: " + aMsg + "\n");
dump("-*- PresentationControlService.js: " + aMsg + "\n");
}
function TCPDeviceInfo(aAddress, aPort, aId) {
@ -20,13 +20,13 @@ function TCPDeviceInfo(aAddress, aPort, aId) {
this.id = aId;
}
function TCPPresentationServer() {
function PresentationControlService() {
this._id = null;
this._port = 0;
this._serverSocket = null;
}
TCPPresentationServer.prototype = {
PresentationControlService.prototype = {
/**
* If a user agent connects to this server, we create a control channel but
* hand it to |TCPDevice.listener| when the initial information exchange
@ -34,9 +34,9 @@ TCPPresentationServer.prototype = {
*/
_controlChannels: [],
startService: function(aPort) {
startServer: function(aPort) {
if (this._isServiceInit()) {
DEBUG && log("TCPPresentationServer - server socket has been initialized");
DEBUG && log("PresentationControlService - server socket has been initialized");
throw Cr.NS_ERROR_FAILURE;
}
@ -50,7 +50,7 @@ TCPPresentationServer.prototype = {
.createInstance(Ci.nsIServerSocket);
if (!this._serverSocket) {
DEBUG && log("TCPPresentationServer - create server socket fail.");
DEBUG && log("PresentationControlService - create server socket fail.");
throw Cr.NS_ERROR_FAILURE;
}
@ -59,13 +59,13 @@ TCPPresentationServer.prototype = {
this._serverSocket.asyncListen(this);
} catch (e) {
// NS_ERROR_SOCKET_ADDRESS_IN_USE
DEBUG && log("TCPPresentationServer - init server socket fail: " + e);
DEBUG && log("PresentationControlService - init server socket fail: " + e);
throw Cr.NS_ERROR_FAILURE;
}
this._port = this._serverSocket.port;
DEBUG && log("TCPPresentationServer - service start on port: " + this._port);
DEBUG && log("PresentationControlService - service start on port: " + this._port);
// Monitor network interface change to restart server socket.
// Only B2G has nsINetworkManager
@ -99,10 +99,10 @@ TCPPresentationServer.prototype = {
requestSession: function(aDeviceInfo, aUrl, aPresentationId) {
if (!this.id) {
DEBUG && log("TCPPresentationServer - Id has not initialized; requestSession fails");
DEBUG && log("PresentationControlService - Id has not initialized; requestSession fails");
return null;
}
DEBUG && log("TCPPresentationServer - requestSession to " + aDeviceInfo.id
DEBUG && log("PresentationControlService - requestSession to " + aDeviceInfo.id
+ ": " + aUrl + ", " + aPresentationId);
let sts = Cc["@mozilla.org/network/socket-transport-service;1"]
@ -116,7 +116,7 @@ TCPPresentationServer.prototype = {
aDeviceInfo.port,
null);
} catch (e) {
DEBUG && log("TCPPresentationServer - createTransport throws: " + e);
DEBUG && log("PresentationControlService - createTransport throws: " + e);
// Pop the exception to |TCPDevice.establishControlChannel|
throw Cr.NS_ERROR_FAILURE;
}
@ -130,11 +130,11 @@ TCPPresentationServer.prototype = {
responseSession: function(aDeviceInfo, aSocketTransport) {
if (!this._isServiceInit()) {
DEBUG && log("TCPPresentationServer - should never receive remote " +
DEBUG && log("PresentationControlService - should never receive remote " +
"session request before server socket initialization");
return null;
}
DEBUG && log("TCPPresentationServer - responseSession to "
DEBUG && log("PresentationControlService - responseSession to "
+ JSON.stringify(aDeviceInfo));
return new TCPControlChannel(this,
aSocketTransport,
@ -147,7 +147,7 @@ TCPPresentationServer.prototype = {
// Triggered by TCPControlChannel
onSessionRequest: function(aDeviceInfo, aUrl, aPresentationId, aControlChannel) {
DEBUG && log("TCPPresentationServer - onSessionRequest: "
DEBUG && log("PresentationControlService - onSessionRequest: "
+ aDeviceInfo.address + ":" + aDeviceInfo.port);
this.listener.onSessionRequest(aDeviceInfo,
aUrl,
@ -158,7 +158,7 @@ TCPPresentationServer.prototype = {
// nsIServerSocketListener (Triggered by nsIServerSocket.init)
onSocketAccepted: function(aServerSocket, aClientSocket) {
DEBUG && log("TCPPresentationServer - onSocketAccepted: "
DEBUG && log("PresentationControlService - onSocketAccepted: "
+ aClientSocket.host + ":" + aClientSocket.port);
let deviceInfo = new TCPDeviceInfo(aClientSocket.host, aClientSocket.port);
this.holdControlChannel(this.responseSession(deviceInfo, aClientSocket));
@ -177,13 +177,13 @@ TCPPresentationServer.prototype = {
// nsIServerSocketListener (Triggered by nsIServerSocket.init)
onStopListening: function(aServerSocket, aStatus) {
DEBUG && log("TCPPresentationServer - onStopListening: " + aStatus);
DEBUG && log("PresentationControlService - onStopListening: " + aStatus);
},
close: function() {
DEBUG && log("TCPPresentationServer - close");
DEBUG && log("PresentationControlService - close");
if (this._isServiceInit()) {
DEBUG && log("TCPPresentationServer - close server socket");
DEBUG && log("PresentationControlService - close server socket");
this._serverSocket.close();
this._serverSocket = null;
@ -195,7 +195,7 @@ TCPPresentationServer.prototype = {
// nsIObserver
observe: function(aSubject, aTopic, aData) {
DEBUG && log("TCPPresentationServer - observe: " + aTopic);
DEBUG && log("PresentationControlService - observe: " + aTopic);
switch (aTopic) {
case "network-active-changed": {
if (!aSubject) {
@ -208,7 +208,7 @@ TCPPresentationServer.prototype = {
* cases will be handled by "network:offline-status-changed".
*/
if (!Services.io.offline) {
this._restartService();
this._restartServer();
}
break;
}
@ -217,14 +217,14 @@ TCPPresentationServer.prototype = {
DEBUG && log("network offline");
return;
}
this._restartService();
this._restartServer();
break;
}
}
},
_restartService: function() {
DEBUG && log("TCPPresentationServer - restart service");
_restartServer: function() {
DEBUG && log("PresentationControlService - restart service");
// restart server socket
if (this._isServiceInit()) {
@ -232,19 +232,19 @@ TCPPresentationServer.prototype = {
this.close();
try {
this.startService();
this.startServer();
if (this._listener && this._port !== port) {
this._listener.onPortChange(this._port);
}
} catch (e) {
DEBUG && log("TCPPresentationServer - restart service fail: " + e);
DEBUG && log("PresentationControlService - restart service fail: " + e);
}
}
},
classID: Components.ID("{f4079b8b-ede5-4b90-a112-5b415a931deb}"),
QueryInterface : XPCOMUtils.generateQI([Ci.nsIServerSocketListener,
Ci.nsITCPPresentationServer,
Ci.nsIPresentationControlService,
Ci.nsIObserver]),
};
@ -316,7 +316,7 @@ function discriptionAsJson(aDescription) {
return json;
}
function TCPControlChannel(presentationServer,
function TCPControlChannel(presentationService,
transport,
deviceInfo,
presentationId,
@ -330,7 +330,7 @@ function TCPControlChannel(presentationServer,
this._transport = transport;
this._url = url;
this._presentationServer = presentationServer;
this._presentationService = presentationService;
let currentThread = Services.tm.currentThread;
transport.setEventSink(this, currentThread);
@ -390,7 +390,7 @@ TCPControlChannel.prototype = {
type: "requestSession:Init",
presentationId: this._presentationId,
url: this._url,
id: this._presentationServer.id,
id: this._presentationService.id,
};
this._sendMessage("init", msg, function(e) {
@ -532,10 +532,10 @@ TCPControlChannel.prototype = {
this._deviceInfo.id = aMsg.id;
this._url = aMsg.url;
this._presentationId = aMsg.presentationId;
this._presentationServer.onSessionRequest(this._deviceInfo,
aMsg.url,
aMsg.presentationId,
this);
this._presentationService.onSessionRequest(this._deviceInfo,
aMsg.url,
aMsg.presentationId,
this);
this._notifyOpened();
break;
}
@ -686,7 +686,7 @@ TCPControlChannel.prototype = {
this._input.close();
this._output.close();
this._presentationServer.releaseControlChannel(this);
this._presentationService.releaseControlChannel(this);
this._connected = false;
}
@ -697,4 +697,4 @@ TCPControlChannel.prototype = {
Ci.nsIStreamListener]),
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TCPPresentationServer]);
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PresentationControlService]);

Просмотреть файл

@ -6,7 +6,7 @@
EXTRA_COMPONENTS += [
'BuiltinProviders.manifest',
'TCPPresentationServer.js'
'PresentationControlService.js'
]
UNIFIED_SOURCES += [

Просмотреть файл

@ -14,7 +14,7 @@ const INFO_CONTRACT_ID = "@mozilla.org/toolkit/components/mdnsresponder/dns-info
const PROVIDER_CONTRACT_ID = "@mozilla.org/presentation-device/multicastdns-provider;1";
const SD_CONTRACT_ID = "@mozilla.org/toolkit/components/mdnsresponder/dns-sd;1";
const UUID_CONTRACT_ID = "@mozilla.org/uuid-generator;1";
const SERVER_CONTRACT_ID = "@mozilla.org/presentation-device/tcp-presentation-server;1";
const SERVER_CONTRACT_ID = "@mozilla.org/presentation/control-service;1";
const PREF_DISCOVERY = "dom.presentation.discovery.enabled";
const PREF_DISCOVERABLE = "dom.presentation.discoverable";
@ -417,7 +417,7 @@ function handleSessionRequest() {
};
let mockServerObj = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITCPPresentationServer]),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlService]),
requestSession: function(deviceInfo, url, presentationId) {
this.request = {
deviceInfo: deviceInfo,
@ -489,8 +489,8 @@ function handleOnSessionRequest() {
};
let mockServerObj = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITCPPresentationServer]),
startService: function() {},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlService]),
startServer: function() {},
sessionRequest: function() {},
close: function() {},
id: '',
@ -531,7 +531,7 @@ function handleOnSessionRequest() {
const testControlChannel = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlChannel]),
};
provider.QueryInterface(Ci.nsITCPPresentationServerListener)
provider.QueryInterface(Ci.nsIPresentationControlServerListener)
.onSessionRequest(deviceInfo, testUrl, testPresentationId, testControlChannel);
Assert.equal(listener.request.deviceId, deviceInfo.id);
@ -555,8 +555,8 @@ function handleOnSessionRequestFromUnknownDevice() {
};
let mockServerObj = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITCPPresentationServer]),
startService: function() {},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlService]),
startServer: function() {},
sessionRequest: function() {},
close: function() {},
id: '',
@ -603,7 +603,7 @@ function handleOnSessionRequestFromUnknownDevice() {
const testControlChannel = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlChannel]),
};
provider.QueryInterface(Ci.nsITCPPresentationServerListener)
provider.QueryInterface(Ci.nsIPresentationControlServerListener)
.onSessionRequest(deviceInfo, testUrl, testPresentationId, testControlChannel);
Assert.equal(listener.request.deviceId, deviceInfo.id);
@ -687,8 +687,8 @@ function ignoreSelfDevice() {
};
let mockServerObj = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITCPPresentationServer]),
startService: function() {},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlService]),
startServer: function() {},
sessionRequest: function() {},
close: function() {},
id: '',
@ -1001,7 +1001,7 @@ function serverClosed() {
Assert.equal(mockObj.serviceUnregistered, 0);
Assert.equal(listener.devices.length, 1);
let serverListener = provider.QueryInterface(Ci.nsITCPPresentationServerListener);
let serverListener = provider.QueryInterface(Ci.nsIPresentationControlServerListener);
let randomPort = 9527;
serverListener.onPortChange(randomPort);

Просмотреть файл

@ -56,10 +56,10 @@ const ANSWER_ADDRESS = '192.168.321.321';
const ANSWER_PORT = 321;
function loopOfferAnser() {
tps = Cc["@mozilla.org/presentation-device/tcp-presentation-server;1"]
.createInstance(Ci.nsITCPPresentationServer);
tps = Cc["@mozilla.org/presentation/control-service;1"]
.createInstance(Ci.nsIPresentationControlService);
tps.id = 'controllerID';
tps.startService(PRESENTER_CONTROL_CHANNEL_PORT);
tps.startServer(PRESENTER_CONTROL_CHANNEL_PORT);
testPresentationServer();
}
@ -125,7 +125,7 @@ function testPresentationServer() {
};
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsITCPPresentationServerListener]),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlServerListener]),
};
let presenterDeviceInfo = {
@ -198,7 +198,7 @@ function setOffline() {
function oneMoreLoop() {
try {
tps.startService(PRESENTER_CONTROL_CHANNEL_PORT);
tps.startServer(PRESENTER_CONTROL_CHANNEL_PORT);
testPresentationServer();
} catch (e) {
Assert.ok(false, 'TCP presentation init fail:' + e);

Просмотреть файл

@ -412,7 +412,7 @@
@BINPATH@/components/PresentationDeviceInfoManager.manifest
@BINPATH@/components/PresentationDeviceInfoManager.js
@BINPATH@/components/BuiltinProviders.manifest
@BINPATH@/components/TCPPresentationServer.js
@BINPATH@/components/PresentationControlService.js
@BINPATH@/components/PresentationNetworkHelper.js
@BINPATH@/components/PresentationNetworkHelper.manifest
@BINPATH@/components/PresentationDataChannelSessionTransport.js
@ -557,4 +557,4 @@
#include @PKG_LOCALE_MANIFEST@
#endif
@BINPATH@/components/dom_audiochannel.xpt
@BINPATH@/components/dom_audiochannel.xpt