Back out 3 changesets (bug 1263799) for bustage.
authorKit Cambridge <kcambridge@mozilla.com>
Mon, 02 May 2016 11:38:55 -0700
changeset 295818 fa3ab4a530b46704a4827f5faf6e389a93a8a6aa
parent 295817 3166fa3db323839e3de19fd95624e7593728e235
child 295819 3b77d0263a1508a79ef3093001a9502fcea9c68f
push id19043
push usercbook@mozilla.com
push dateTue, 03 May 2016 14:20:17 +0000
treeherderfx-team@7f959c47385b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1263799
milestone49.0a1
backs outd379317d86df1a47cae66916db0306a60d343881
067e84f524d11e3582615fd18a28c40f046e4779
8f31424a9d07a81574ad59b415a97e289ffb5fb0
Back out 3 changesets (bug 1263799) for bustage. Backed out changeset d379317d86df (bug 1263799) Backed out changeset 067e84f524d1 (bug 1263799) Backed out changeset 8f31424a9d07 (bug 1263799) MozReview-Commit-ID: KJ9b8tC5k4n
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/tv/TVChannel.cpp
dom/tv/TVChannel.h
dom/tv/TVListeners.cpp
dom/tv/TVListeners.h
dom/tv/TVManager.cpp
dom/tv/TVManager.h
dom/tv/TVServiceCallbacks.cpp
dom/tv/TVServiceFactory.cpp
dom/tv/TVServiceFactory.h
dom/tv/TVServiceRunnables.h
dom/tv/TVSimulatorService.js
dom/tv/TVSource.cpp
dom/tv/TVSource.h
dom/tv/TVTuner.cpp
dom/tv/TVTuner.h
dom/tv/TVTypes.cpp
dom/tv/TVTypes.h
dom/tv/gonk/TVGonkService.cpp
dom/tv/gonk/TVGonkService.h
dom/tv/ipc/PTV.ipdl
dom/tv/ipc/PTVRequest.ipdl
dom/tv/ipc/PTVTypes.ipdlh
dom/tv/ipc/TVChild.cpp
dom/tv/ipc/TVChild.h
dom/tv/ipc/TVIPCHelper.cpp
dom/tv/ipc/TVIPCHelper.h
dom/tv/ipc/TVIPCService.cpp
dom/tv/ipc/TVIPCService.h
dom/tv/ipc/TVParent.cpp
dom/tv/ipc/TVParent.h
dom/tv/moz.build
dom/tv/nsITVService.idl
dom/tv/nsITVSimulatorService.idl
dom/tv/test/mochitest/head.js
dom/tv/test/mochitest/mochitest.ini
dom/tv/test/mochitest/test_tv_eit_broadcasted.html
dom/tv/test/mochitest/test_tv_scan_channels_completed.html
dom/tv/test/mochitest/test_tv_scan_channels_error.html
dom/tv/test/mochitest/tv_chrome_script.js
layout/build/nsLayoutModule.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -176,17 +176,16 @@
 #include "mozilla/dom/icc/IccChild.h"
 #include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
 #include "mozilla/dom/mobilemessage/SmsChild.h"
 #include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
 #include "mozilla/dom/bluetooth/PBluetoothChild.h"
 #include "mozilla/dom/PFMRadioChild.h"
 #include "mozilla/dom/PPresentationChild.h"
 #include "mozilla/dom/PresentationIPCService.h"
-#include "mozilla/dom/PTVChild.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 
 #ifdef MOZ_WEBSPEECH
 #include "mozilla/dom/PSpeechSynthesisChild.h"
 #endif
 
 #include "ProcessUtils.h"
 #include "URIUtils.h"
@@ -1692,29 +1691,16 @@ ContentChild::RecvNotifyPresentationRece
     do_GetService(PRESENTATION_SERVICE_CONTRACTID);
   NS_WARN_IF(!service);
 
   NS_WARN_IF(NS_FAILED(service->UntrackSessionInfo(aSessionId, nsIPresentationService::ROLE_RECEIVER)));
 
   return true;
 }
 
-PTVChild*
-ContentChild::AllocPTVChild()
-{
-  NS_NOTREACHED("We should never be manually allocating PTVChild actors");
-  return nullptr;
-}
-
-bool
-ContentChild::DeallocPTVChild(PTVChild* aActor)
-{
-  return true;
-}
-
 bool
 ContentChild::RecvNotifyGMPsChanged()
 {
   GMPDecoderModule::UpdateUsableCodecs();
   return true;
 }
 
 PCrashReporterChild*
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -360,20 +360,16 @@ public:
 
   virtual bool
   RecvNotifyPresentationReceiverLaunched(PBrowserChild* aIframe,
                                          const nsString& aSessionId) override;
 
   virtual bool
   RecvNotifyPresentationReceiverCleanUp(const nsString& aSessionId) override;
 
-  virtual PTVChild* AllocPTVChild() override;
-
-  virtual bool DeallocPTVChild(PTVChild* aActor) override;
-
   virtual bool RecvNotifyGMPsChanged() override;
 
   virtual PSpeechSynthesisChild* AllocPSpeechSynthesisChild() override;
 
   virtual bool DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor) override;
 
   virtual bool RecvRegisterChrome(InfallibleTArray<ChromePackage>&& packages,
                                   InfallibleTArray<SubstitutionMapping>&& resources,
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -66,17 +66,16 @@
 #include "mozilla/dom/mobilemessage/SmsParent.h"
 #include "mozilla/dom/power/PowerManagerService.h"
 #include "mozilla/dom/Permissions.h"
 #include "mozilla/dom/PresentationParent.h"
 #include "mozilla/dom/PPresentationParent.h"
 #include "mozilla/dom/quota/QuotaManagerService.h"
 #include "mozilla/dom/telephony/TelephonyParent.h"
 #include "mozilla/dom/time/DateCacheCleaner.h"
-#include "mozilla/dom/TVParent.h"
 #include "mozilla/dom/voicemail/VoicemailParent.h"
 #include "mozilla/embedding/printingui/PrintingParent.h"
 #include "mozilla/hal_sandbox/PHalParent.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/BackgroundParent.h"
 #include "mozilla/ipc/FileDescriptorSetParent.h"
 #include "mozilla/ipc/FileDescriptorUtils.h"
 #include "mozilla/ipc/PFileDescriptorSetParent.h"
@@ -4104,36 +4103,16 @@ ContentParent::DeallocPPresentationParen
 }
 
 bool
 ContentParent::RecvPPresentationConstructor(PPresentationParent* aActor)
 {
   return static_cast<PresentationParent*>(aActor)->Init();
 }
 
-PTVParent*
-ContentParent::AllocPTVParent()
-{
-  RefPtr<TVParent> actor = new TVParent();
-  return actor.forget().take();
-}
-
-bool
-ContentParent::DeallocPTVParent(PTVParent* aActor)
-{
-  RefPtr<TVParent> actor = dont_AddRef(static_cast<TVParent*>(aActor));
-  return true;
-}
-
-bool
-ContentParent::RecvPTVConstructor(PTVParent* aActor)
-{
-  return static_cast<TVParent*>(aActor)->Init();
-}
-
 PSpeechSynthesisParent*
 ContentParent::AllocPSpeechSynthesisParent()
 {
 #ifdef MOZ_WEBSPEECH
   return new mozilla::dom::SpeechSynthesisParent();
 #else
   return nullptr;
 #endif
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -862,22 +862,16 @@ private:
   virtual bool DeallocPFMRadioParent(PFMRadioParent* aActor) override;
 
   virtual PPresentationParent* AllocPPresentationParent() override;
 
   virtual bool DeallocPPresentationParent(PPresentationParent* aActor) override;
 
   virtual bool RecvPPresentationConstructor(PPresentationParent* aActor) override;
 
-  virtual PTVParent* AllocPTVParent() override;
-
-  virtual bool DeallocPTVParent(PTVParent* aActor) override;
-
-  virtual bool RecvPTVConstructor(PTVParent* aActor) override;
-
   virtual PSpeechSynthesisParent* AllocPSpeechSynthesisParent() override;
 
   virtual bool
   DeallocPSpeechSynthesisParent(PSpeechSynthesisParent* aActor) override;
 
   virtual bool
   RecvPSpeechSynthesisConstructor(PSpeechSynthesisParent* aActor) override;
 
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -51,17 +51,16 @@ include protocol PTelephony;
 include protocol PTestShell;
 include protocol PVoicemail;
 include protocol PJavaScript;
 include protocol PRemoteSpellcheckEngine;
 include protocol PWebBrowserPersistDocument;
 include protocol PWebrtcGlobal;
 include protocol PPresentation;
 include protocol PVRManager;
-include protocol PTV;
 include DOMTypes;
 include JavaScriptTypes;
 include InputStreamParams;
 include PTabContext;
 include URIParams;
 include PluginTypes;
 include ProtocolTypes;
 include PBackgroundSharedTypes;
@@ -426,17 +425,16 @@ prio(normal upto urgent) sync protocol P
     manages PTelephony;
     manages PTestShell;
     manages PVoicemail;
     manages PJavaScript;
     manages PRemoteSpellcheckEngine;
     manages PWebBrowserPersistDocument;
     manages PWebrtcGlobal;
     manages PPresentation;
-    manages PTV;
 
 both:
     // Depending on exactly how the new browser is being created, it might be
     // created from either the child or parent process!
     //
     // The child creates the PBrowser as part of
     // TabChild::BrowserFrameProvideWindow (which happens when the child's
     // content calls window.open()), and the parent creates the PBrowser as part
@@ -843,18 +841,16 @@ parent:
     async PBluetooth();
 
     async PFMRadio();
 
     async PWebrtcGlobal();
 
     async PPresentation();
 
-    async PTV();
-
     // Services remoting
 
     async StartVisitedQuery(URIParams uri);
     async VisitURI(URIParams uri, OptionalURIParams referrer, uint32_t flags);
     async SetURITitle(URIParams uri, nsString title);
 
     async LoadURIExternal(URIParams uri, PBrowser windowContext);
 
--- a/dom/tv/TVChannel.cpp
+++ b/dom/tv/TVChannel.cpp
@@ -12,17 +12,18 @@
 #include "mozilla/dom/TVUtils.h"
 #include "nsITVService.h"
 #include "nsServiceManagerUtils.h"
 #include "TVChannel.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(TVChannel, DOMEventTargetHelper, mSource)
+NS_IMPL_CYCLE_COLLECTION_INHERITED(TVChannel, DOMEventTargetHelper,
+                                   mTVService, mSource)
 
 NS_IMPL_ADDREF_INHERITED(TVChannel, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(TVChannel, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TVChannel)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 TVChannel::TVChannel(nsPIDOMWindowInner* aWindow,
@@ -61,16 +62,19 @@ TVChannel::Init(nsITVChannelData* aData)
   aData->GetNetworkId(mNetworkId);
   aData->GetTransportStreamId(mTransportStreamId);
   aData->GetServiceId(mServiceId);
   aData->GetName(mName);
   aData->GetNumber(mNumber);
   aData->GetIsEmergency(&mIsEmergency);
   aData->GetIsFree(&mIsFree);
 
+  mTVService = TVServiceFactory::AutoCreateTVService();
+  NS_ENSURE_TRUE(mTVService, false);
+
   return true;
 }
 
 /* virtual */ JSObject*
 TVChannel::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return TVChannelBinding::Wrap(aCx, this, aGivenProto);
 }
@@ -87,36 +91,35 @@ TVChannel::GetPrograms(const TVGetProgra
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
   MOZ_ASSERT(global);
 
   RefPtr<Promise> promise = Promise::Create(global, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-  }
-
   RefPtr<TVTuner> tuner = mSource->Tuner();
   nsString tunerId;
   tuner->GetId(tunerId);
 
   uint64_t startTime = aOptions.mStartTime.WasPassed() ?
                        aOptions.mStartTime.Value() :
                        PR_Now();
   uint64_t endTime = aOptions.mDuration.WasPassed() ?
                      (startTime + aOptions.mDuration.Value()) :
                      std::numeric_limits<uint64_t>::max();
   nsCOMPtr<nsITVServiceCallback> callback =
     new TVServiceProgramGetterCallback(this, promise, false);
   nsresult rv =
-    service->GetPrograms(tunerId, ToTVSourceTypeStr(mSource->Type()), mNumber,
-                         startTime, endTime, callback);
+    mTVService->GetPrograms(tunerId,
+                            ToTVSourceTypeStr(mSource->Type()),
+                            mNumber,
+                            startTime,
+                            endTime,
+                            callback);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
   }
 
   return promise.forget();
 }
 
 void
@@ -180,31 +183,30 @@ TVChannel::GetCurrentProgram(ErrorResult
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
   MOZ_ASSERT(global);
 
   RefPtr<Promise> promise = Promise::Create(global, aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
 
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-  }
-
   RefPtr<TVTuner> tuner = mSource->Tuner();
   nsString tunerId;
   tuner->GetId(tunerId);
 
   // Get only one program from now on.
   nsCOMPtr<nsITVServiceCallback> callback =
     new TVServiceProgramGetterCallback(this, promise, true);
-  nsresult rv = service->GetPrograms(
-    tunerId, ToTVSourceTypeStr(mSource->Type()), mNumber, PR_Now(),
-    std::numeric_limits<uint64_t>::max(), callback);
+  nsresult rv =
+    mTVService->GetPrograms(tunerId,
+                            ToTVSourceTypeStr(mSource->Type()),
+                            mNumber,
+                            PR_Now(),
+                            std::numeric_limits<uint64_t>::max(),
+                            callback);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
   }
 
   return promise.forget();
 }
 
 } // namespace dom
--- a/dom/tv/TVChannel.h
+++ b/dom/tv/TVChannel.h
@@ -7,16 +7,17 @@
 #ifndef mozilla_dom_TVChannel_h
 #define mozilla_dom_TVChannel_h
 
 #include "mozilla/DOMEventTargetHelper.h"
 // Include TVChannelBinding.h since enum TVChannelType can't be forward declared.
 #include "mozilla/dom/TVChannelBinding.h"
 
 class nsITVChannelData;
+class nsITVService;
 
 namespace mozilla {
 namespace dom {
 
 class Promise;
 class TVSource;
 
 class TVChannel final : public DOMEventTargetHelper
@@ -64,16 +65,17 @@ public:
 private:
   TVChannel(nsPIDOMWindowInner* aWindow,
             TVSource* aSource);
 
   ~TVChannel();
 
   bool Init(nsITVChannelData* aData);
 
+  nsCOMPtr<nsITVService> mTVService;
   RefPtr<TVSource> mSource;
   nsString mNetworkId;
   nsString mTransportStreamId;
   nsString mServiceId;
   TVChannelType mType;
   nsString mNumber;
   nsString mName;
   bool mIsEmergency;
--- a/dom/tv/TVListeners.cpp
+++ b/dom/tv/TVListeners.cpp
@@ -7,131 +7,96 @@
 #include "mozilla/dom/TVSource.h"
 #include "mozilla/dom/TVTuner.h"
 #include "mozilla/dom/TVUtils.h"
 #include "TVListeners.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(TVSourceListener)
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TVSourceListener)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSource)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(TVSourceListener)
-  tmp->Shutdown();
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mSource)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+NS_IMPL_CYCLE_COLLECTION(TVSourceListener, mSources)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(TVSourceListener)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(TVSourceListener)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TVSourceListener)
   NS_INTERFACE_MAP_ENTRY(nsITVSourceListener)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
-/* static */ already_AddRefed<TVSourceListener>
-TVSourceListener::Create(TVSource* aSource)
-{
-  RefPtr<TVSourceListener> listener = new TVSourceListener(aSource);
-  return (listener->Init()) ? listener.forget() : nullptr;
-}
-
-TVSourceListener::TVSourceListener(TVSource* aSource) : mSource(aSource)
-{
-  MOZ_ASSERT(mSource);
-}
-
-TVSourceListener::~TVSourceListener()
+void
+TVSourceListener::RegisterSource(TVSource* aSource)
 {
-  Shutdown();
-}
-
-bool
-TVSourceListener::Init()
-{
-  RefPtr<TVTuner> tuner = mSource->Tuner();
-  tuner->GetId(mTunerId);
-
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    return false;
-  }
-
-  nsresult rv = service->RegisterSourceListener(
-    mTunerId, ToTVSourceTypeStr(mSource->Type()), this);
-  return NS_WARN_IF(NS_FAILED(rv)) ? false : true;
+  mSources.AppendElement(aSource);
 }
 
 void
-TVSourceListener::Shutdown()
+TVSourceListener::UnregisterSource(TVSource* aSource)
 {
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    return;
+  for (uint32_t i = 0; i < mSources.Length(); i++) {
+    if (mSources[i] == aSource) {
+      mSources.RemoveElementsAt(i, 1);
+    }
   }
-
-  nsresult rv = service->UnregisterSourceListener(
-    mTunerId, ToTVSourceTypeStr(mSource->Type()), this);
-  NS_WARN_IF(NS_FAILED(rv));
 }
 
 /* virtual */ NS_IMETHODIMP
 TVSourceListener::NotifyChannelScanned(const nsAString& aTunerId,
                                        const nsAString& aSourceType,
                                        nsITVChannelData* aChannelData)
 {
-  if (NS_WARN_IF(!IsMatched(aTunerId, aSourceType))) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return mSource->NotifyChannelScanned(aChannelData);
+  RefPtr<TVSource> source = GetSource(aTunerId, aSourceType);
+  source->NotifyChannelScanned(aChannelData);
+  return NS_OK;
 }
 
 /* virtual */ NS_IMETHODIMP
 TVSourceListener::NotifyChannelScanComplete(const nsAString& aTunerId,
                                             const nsAString& aSourceType)
 {
-  if (NS_WARN_IF(!IsMatched(aTunerId, aSourceType))) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return mSource->NotifyChannelScanComplete();
+  RefPtr<TVSource> source = GetSource(aTunerId, aSourceType);
+  source->NotifyChannelScanComplete();
+  return NS_OK;
 }
 
 /* virtual */ NS_IMETHODIMP
 TVSourceListener::NotifyChannelScanStopped(const nsAString& aTunerId,
                                            const nsAString& aSourceType)
 {
-  if (NS_WARN_IF(!IsMatched(aTunerId, aSourceType))) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return mSource->NotifyChannelScanStopped();
+  RefPtr<TVSource> source = GetSource(aTunerId, aSourceType);
+  source->NotifyChannelScanStopped();
+  return NS_OK;
 }
 
 /* virtual */ NS_IMETHODIMP
 TVSourceListener::NotifyEITBroadcasted(const nsAString& aTunerId,
                                        const nsAString& aSourceType,
                                        nsITVChannelData* aChannelData,
                                        nsITVProgramData** aProgramDataList,
                                        const uint32_t aCount)
 {
-  if (NS_WARN_IF(!IsMatched(aTunerId, aSourceType))) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return mSource->NotifyEITBroadcasted(aChannelData, aProgramDataList, aCount);
+  RefPtr<TVSource> source = GetSource(aTunerId, aSourceType);
+  source->NotifyEITBroadcasted(aChannelData, aProgramDataList, aCount);
+  return NS_OK;
 }
 
-bool
-TVSourceListener::IsMatched(const nsAString& aTunerId,
+already_AddRefed<TVSource>
+TVSourceListener::GetSource(const nsAString& aTunerId,
                             const nsAString& aSourceType)
 {
-  return aTunerId.Equals(mTunerId) &&
-         ToTVSourceType(aSourceType) == mSource->Type();
+  for (uint32_t i = 0; i < mSources.Length(); i++) {
+    nsString tunerId;
+    RefPtr<TVTuner> tuner = mSources[i]->Tuner();
+    tuner->GetId(tunerId);
+
+    nsString sourceType = ToTVSourceTypeStr(mSources[i]->Type());
+
+    if (aTunerId.Equals(tunerId) && aSourceType.Equals(sourceType)) {
+      RefPtr<TVSource> source = mSources[i];
+      return source.forget();
+    }
+  }
+
+  return nullptr;
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/tv/TVListeners.h
+++ b/dom/tv/TVListeners.h
@@ -2,54 +2,40 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_TVListeners_h
 #define mozilla_dom_TVListeners_h
 
+#include "mozilla/dom/TVSource.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsITVService.h"
+#include "nsTArray.h"
 
 namespace mozilla {
 namespace dom {
 
-class TVSource;
-
-/*
- * Instead of making |TVSource| class implement |TVSource| (WebIDL) and
- * |nsITVSourceListener| (XPCOM) at the same time, having an individual class
- * for |nsITVSourceListener| (XPCOM) interface would help the JS context
- * recognize |nsITVSourceListener| instances (when it comes to use them in
- * |TVSimulatorService.js|.)
- */
 class TVSourceListener final : public nsITVSourceListener
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(TVSourceListener)
   NS_DECL_NSITVSOURCELISTENER
 
-  static already_AddRefed<TVSourceListener> Create(TVSource* aSource);
+  void RegisterSource(TVSource* aSource);
+
+  void UnregisterSource(TVSource* aSource);
 
 private:
-  explicit TVSourceListener(TVSource* aSource);
-
-  ~TVSourceListener();
-
-  bool Init();
-
-  void Shutdown();
+  ~TVSourceListener() {}
 
-  bool IsMatched(const nsAString& aTunerId, const nsAString& aSourceType);
-
-  RefPtr<TVSource> mSource;
+  already_AddRefed<TVSource> GetSource(const nsAString& aTunerId,
+                                       const nsAString& aSourceType);
 
-  // Store the tuner ID for |UnregisterSourceListener| call in |Shutdown| since
-  // |mSource->Tuner()| may not exist at that moment.
-  nsString mTunerId;
+  nsTArray<RefPtr<TVSource>> mSources;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_TVListeners_h
--- a/dom/tv/TVManager.cpp
+++ b/dom/tv/TVManager.cpp
@@ -11,18 +11,18 @@
 #include "mozilla/dom/TVTuner.h"
 #include "nsITVService.h"
 #include "nsServiceManagerUtils.h"
 #include "TVManager.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(TVManager, DOMEventTargetHelper, mTuners,
-                                   mPendingGetTunersPromises)
+NS_IMPL_CYCLE_COLLECTION_INHERITED(TVManager, DOMEventTargetHelper, mTVService,
+                                   mTuners, mPendingGetTunersPromises)
 
 NS_IMPL_ADDREF_INHERITED(TVManager, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(TVManager, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TVManager)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 TVManager::TVManager(nsPIDOMWindowInner* aWindow)
@@ -40,23 +40,21 @@ TVManager::Create(nsPIDOMWindowInner* aW
 {
   RefPtr<TVManager> manager = new TVManager(aWindow);
   return (manager->Init()) ? manager.forget() : nullptr;
 }
 
 bool
 TVManager::Init()
 {
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    return false;
-  }
+  mTVService = TVServiceFactory::AutoCreateTVService();
+  NS_ENSURE_TRUE(mTVService, false);
 
   nsCOMPtr<nsITVServiceCallback> callback = new TVServiceTunerGetterCallback(this);
-  nsresult rv = service->GetTuners(callback);
+  nsresult rv = mTVService->GetTuners(callback);
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 /* virtual */ JSObject*
 TVManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
--- a/dom/tv/TVManager.h
+++ b/dom/tv/TVManager.h
@@ -4,16 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_TVManager_h
 #define mozilla_dom_TVManager_h
 
 #include "mozilla/DOMEventTargetHelper.h"
 
+class nsITVService;
+
 namespace mozilla {
 namespace dom {
 
 class Promise;
 class TVTuner;
 
 class TVManager final : public DOMEventTargetHelper
 {
@@ -39,16 +41,17 @@ public:
 
 private:
   explicit TVManager(nsPIDOMWindowInner* aWindow);
 
   ~TVManager();
 
   bool Init();
 
+  nsCOMPtr<nsITVService> mTVService;
   nsTArray<RefPtr<TVTuner>> mTuners;
   bool mIsReady;
   nsTArray<RefPtr<Promise>> mPendingGetTunersPromises;
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/tv/TVServiceCallbacks.cpp
+++ b/dom/tv/TVServiceCallbacks.cpp
@@ -42,41 +42,23 @@ TVServiceSourceSetterCallback::TVService
 
 TVServiceSourceSetterCallback::~TVServiceSourceSetterCallback()
 {
 }
 
 /* virtual */ NS_IMETHODIMP
 TVServiceSourceSetterCallback::NotifySuccess(nsIArray* aDataList)
 {
-  // |aDataList| is expected to be with only one element.
-  if (!aDataList) {
+  // |aDataList| is expected to be null for setter callbacks.
+  if (aDataList) {
     mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
     return NS_ERROR_INVALID_ARG;
   }
 
-  uint32_t length;
-  nsresult rv = aDataList->GetLength(&length);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-    return rv;
-  }
-  if (length != 1) {
-    mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  nsCOMPtr<nsITVGonkNativeHandleData> handleData =
-    do_QueryElementAt(aDataList, 0);
-  if (NS_WARN_IF(!handleData)) {
-    mPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  rv = mTuner->SetCurrentSource(mSourceType, handleData);
+  nsresult rv = mTuner->SetCurrentSource(mSourceType);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     mPromise->MaybeReject(rv);
     return rv;
   }
 
   mPromise->MaybeResolve(JS::UndefinedHandleValue);
   return NS_OK;
 }
--- a/dom/tv/TVServiceFactory.cpp
+++ b/dom/tv/TVServiceFactory.cpp
@@ -1,44 +1,40 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "TVServiceFactory.h"
-
-#ifdef MOZ_WIDGET_GONK
-#include "gonk/TVGonkService.h"
-#endif
-#include "ipc/TVIPCService.h"
+#include "mozilla/dom/TVListeners.h"
+#include "mozilla/Preferences.h"
 #include "nsITVService.h"
 #include "nsITVSimulatorService.h"
 #include "nsServiceManagerUtils.h"
-
+#include "TVServiceFactory.h"
 
 namespace mozilla {
 namespace dom {
 
 /* static */ already_AddRefed<nsITVService>
 TVServiceFactory::AutoCreateTVService()
 {
-  nsCOMPtr<nsITVService> service;
+  nsresult rv = NS_OK;
+  nsCOMPtr<nsITVService> service = do_CreateInstance(TV_SERVICE_CONTRACTID);
+  if (!service) {
+    // Fallback to the TV Simulator Service
+    service = do_CreateInstance(TV_SIMULATOR_SERVICE_CONTRACTID, &rv);
 
-  if (GeckoProcessType_Default != XRE_GetProcessType()) {
-    service = new TVIPCService();
-    return service.forget();
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return nullptr;
+    }
   }
 
-#ifdef MOZ_WIDGET_GONK
-  service = new TVGonkService();
-#endif
-
-  if (!service) {
-    // Fallback to TV simulator service, especially for TV simulator on WebIDE.
-    service = do_CreateInstance(TV_SIMULATOR_SERVICE_CONTRACTID);
+  rv = service->SetSourceListener(new TVSourceListener());
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return nullptr;
   }
 
   return service.forget();
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/tv/TVServiceFactory.h
+++ b/dom/tv/TVServiceFactory.h
@@ -4,19 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_TVServiceFactory_h
 #define mozilla_dom_TVServiceFactory_h
 
 #include "nsCOMPtr.h"
 
-#define TV_SERVICE_CID \
-  { 0x60fb3c53, 0x017f, 0x4340, { 0x91, 0x1b, 0xd5, 0x5c, 0x31, 0x28, 0x88, 0xb6 } }
-
 class nsITVService;
 
 namespace mozilla {
 namespace dom {
 
 class TVServiceFactory
 {
 public:
--- a/dom/tv/TVServiceRunnables.h
+++ b/dom/tv/TVServiceRunnables.h
@@ -27,19 +27,17 @@ class TVServiceNotifyRunnable final : pu
 {
 public:
   TVServiceNotifyRunnable(nsITVServiceCallback* aCallback,
                           nsIArray* aDataList,
                           uint16_t aErrorCode = nsITVServiceCallback::TV_ERROR_OK)
     : mCallback(aCallback)
     , mDataList(aDataList)
     , mErrorCode(aErrorCode)
-  {
-    MOZ_ASSERT(mCallback);
-  }
+  {}
 
   NS_IMETHOD Run()
   {
     if (mErrorCode == nsITVServiceCallback::TV_ERROR_OK) {
       return mCallback->NotifySuccess(mDataList);
     } else {
       return mCallback->NotifyError(mErrorCode);
     }
--- a/dom/tv/TVSimulatorService.js
+++ b/dom/tv/TVSimulatorService.js
@@ -9,78 +9,75 @@ function debug(aMsg) {
 
 const Cc = Components.classes;
 const Cu = Components.utils;
 const Ci = Components.interfaces;
 const Cr = Components.returnCode;
 
 Cu.importGlobalProperties(["File"]);
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const TV_SIMULATOR_DUMMY_DIRECTORY   = "dummy";
 const TV_SIMULATOR_DUMMY_FILE        = "settings.json";
 
 // See http://seanyhlin.github.io/TV-Manager-API/#idl-def-TVSourceType
 const TV_SOURCE_TYPES = ["dvb-t","dvb-t2","dvb-c","dvb-c2","dvb-s",
                          "dvb-s2","dvb-h","dvb-sh","atsc","atsc-m/h",
                          "isdb-t","isdb-tb","isdb-s","isdb-c","1seg",
                          "dtmb","cmmb","t-dmb","s-dmb"];
 function containInvalidSourceType(aElement, aIndex, aArray) {
   return !TV_SOURCE_TYPES.includes(aElement);
 }
 
 // See http://seanyhlin.github.io/TV-Manager-API/#idl-def-TVChannelType
 const TV_CHANNEL_TYPES = ["tv","radio","data"];
 
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
 function TVSimulatorService() {
-  // This is used for saving the registered source listeners. The object literal
-  // is defined as below:
-  // {
-  //   "tunerId1": {
-  //     "sourceType1": [ /* source listeners */ ],
-  //     "sourceType2": [ /* source listeners */ ],
-  //     ...
-  //   },
-  //   ...
-  // }
-  this._sourceListeners = {};
   this._internalTuners = null;
-  try {
-    this.initData();
-  } catch (e) {
-    debug("Error: " + e + ", Cannot init the data.");
-  }
+  this._scanCompleteTimer = null;
+  this._scanningWrapTunerData = null;
+  this._init();
 }
 
 TVSimulatorService.prototype = {
   classID: Components.ID("{94b065ad-d45a-436a-b394-6dabc3cf110f}"),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsITVSimulatorService,
-                                         Ci.nsITVService]),
+                                         Ci.nsITVService,
+                                         Ci.nsITimerCallback]),
+
+  _init: function TVSimInit() {
+    if (this._internalTuners) {
+      return;
+    }
 
-  initData: function(aMockedData) {
-    // Use the passed-in mocked data. If it doesn't exist, then try to load the
-    // simulation data.
-    let settingStr = aMockedData;
-    if (!settingStr) {
+    // I try to load the testing mock data if related preference are already set.
+    // Otherwise, use to the simulation data from prefences.
+    // See /dom/tv/test/mochitest/head.js for more details.
+    let settingStr = "";
+    try {
+      settingStr = Services.prefs.getCharPref("dom.testing.tv_mock_data");
+    } catch(e) {
       try {
         settingStr = this._getDummyData();
       } catch(e) {
         debug("TV Simulator service failed to load simulation data: " + e);
-        throw Cr.NS_ERROR_FAILURE;
+        return;
       }
     }
 
     let settingsObj;
     try {
       /*
        *
        * Setting JSON file format:
        *
-       * Note: Empty arrays are not allowed in the format.
+       * Note: This setting JSON is not allow empty array.
+       *       If set the empty array, _init() will fail.
        *       e.g.
        *        - "tuners": []
        *        - "channels":[]
        * Format:
        *   {
        *    "tuners": [{
        *      "id":                     "The ID of the tuner",
        *      "supportedType":          ["The array of source type to be used."],
@@ -109,23 +106,23 @@ TVSimulatorService.prototype = {
        *         },]
        *       },]
        *     },]
        *   }
        */
       settingsObj = JSON.parse(settingStr);
     } catch(e) {
       debug("File load error: " + e);
-      throw Cr.NS_ERROR_FAILURE;
+      return;
     }
 
     // validation
     if (!this._validateSettings(settingsObj)) {
       debug("Failed to validate settings.");
-      throw Cr.NS_ERROR_INVALID_ARG;
+      return;
     }
 
     // Key is as follow
     // {'tunerId':tunerId, 'sourceType':sourceType}
     this._internalTuners = new Map();
 
     // TVTunerData
     for (let tunerData of settingsObj.tuners) {
@@ -195,271 +192,239 @@ TVSimulatorService.prototype = {
         }));
         this._internalTuners.set(
                 this._getTunerMapKey(tuner.id, sourceData.type),
                 wrapTunerData);
       }
     }
   },
 
-  registerSourceListener: function(aTunerId, aSourceType, aListener) {
-    let tunerSourceListeners = this._sourceListeners[aTunerId];
-    if (!tunerSourceListeners) {
-      tunerSourceListeners = this._sourceListeners[aTunerId] = {};
-    }
-
-    let listeners = tunerSourceListeners[aSourceType];
-    if (!listeners) {
-      listeners = tunerSourceListeners[aSourceType] = [];
-    }
-
-    if (listeners.indexOf(aListener) < 0) {
-      listeners.push(aListener);
-    }
-  },
-
-  unregisterSourceListener: function(aTunerId, aSourceType, aListener) {
-    let tunerSourceListeners = this._sourceListeners[aTunerId];
-    if (!tunerSourceListeners) {
-      return;
-    }
-
-    let listeners = tunerSourceListeners[aSourceType];
-    if (!listeners) {
-      return;
-    }
-
-    let index = listeners.indexOf(aListener);
-    if (index < 0) {
-      return;
-    }
-
-    listeners.splice(index, 1);
-  },
-
-  _getSourceListeners: function(aTunerId, aSourceType) {
-    let tunerSourceListeners = this._sourceListeners[aTunerId];
-    if (!tunerSourceListeners) {
-      return [];
-    }
-
-    let listeners = tunerSourceListeners[aSourceType];
-    if (!listeners) {
-      return [];
-    }
-
-    return listeners;
-  },
-
-  getTuners: function(aCallback) {
+  getTuners: function TVSimGetTuners(aCallback) {
     if (!aCallback) {
       debug("aCallback is null\n");
-      throw Cr.NS_ERROR_INVALID_ARG;
+      return Cr.NS_ERROR_INVALID_ARG;
     }
 
     let tuners = Cc["@mozilla.org/array;1"]
                    .createInstance(Ci.nsIMutableArray);
 
     for (let [k,wrapTunerData] of this._internalTuners) {
       tuners.appendElement(wrapTunerData.tuner, false);
     }
 
-    aCallback.notifySuccess(tuners);
+    return aCallback.notifySuccess(tuners);
   },
 
-  setSource: function(aTunerId, aSourceType, aCallback) {
+  setSource: function TVSimSetSource(aTunerId, aSourceType, aCallback) {
     if (!aCallback) {
       debug("aCallback is null\n");
-      throw NS_ERROR_INVALID_ARG;
+      return NS_ERROR_INVALID_ARG;
     }
 
     let wrapTunerData = this._getWrapTunerData(aTunerId, aSourceType);
     if (!wrapTunerData) {
-      aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
-      return;
+      return aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
     }
-
-    let streamHandle = Cc["@mozilla.org/tv/tvgonknativehandledata;1"]
-                         .createInstance(Ci.nsITVGonkNativeHandleData);
-    let streamHandles = Cc["@mozilla.org/array;1"]
-                          .createInstance(Ci.nsIMutableArray);
-    streamHandles.appendElement(streamHandle, false);
-
-    aCallback.notifySuccess(streamHandles);
+    return aCallback.notifySuccess(null);
   },
 
-  startScanningChannels: function(aTunerId, aSourceType, aCallback) {
+  startScanningChannels: function TVSimStartScanningChannels(aTunerId, aSourceType, aCallback) {
     if (!aCallback) {
       debug("aCallback is null\n");
-      throw Cr.NS_ERROR_INVALID_ARG;
+      return Cr.NS_ERROR_INVALID_ARG;
     }
 
     let wrapTunerData = this._getWrapTunerData(aTunerId, aSourceType);
     if (!wrapTunerData || !wrapTunerData.channels) {
-      aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
+      return aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
+    }
+
+    if (this._scanningWrapTunerData) {
+      return aCallback.notifyError(Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
+    }
+
+    this._scanningWrapTunerData = wrapTunerData;
+
+    aCallback.notifySuccess(null);
+
+    for (let [key, wrapChannelData] of wrapTunerData.channels) {
+      this._sourceListener.notifyChannelScanned(
+                                        wrapTunerData.tuner.id,
+                                        wrapTunerData.sourceType,
+                                        wrapChannelData.channel);
+    }
+
+    this._scanCompleteTimer = Cc["@mozilla.org/timer;1"]
+                                .createInstance(Ci.nsITimer);
+    let rv = this._scanCompleteTimer.initWithCallback(this, 10,
+                                                      Ci.nsITimer.TYPE_ONE_SHOT);
+    return Cr.NS_OK;
+  },
+
+  notify: function TVSimTimerCallback(aTimer) {
+    if (!this._scanningWrapTunerData) {
       return;
     }
 
-    aCallback.notifySuccess(null);
+    this._scanCompleteTimer = null;
+    let notifyResult = this._sourceListener.notifyChannelScanComplete(
+                                                  this._scanningWrapTunerData.tuner.id,
+                                                  this._scanningWrapTunerData.sourceType);
+    this._scanningWrapTunerData = null;
+    return notifyResult;
   },
 
-  stopScanningChannels: function(aTunerId, aSourceType, aCallback) {
-
+  stopScanningChannels: function TVSimStopScanningChannels(aTunerId, aSourceType, aCallback) {
     if (!aCallback) {
       debug("aCallback is null\n");
-      throw Cr.NS_ERROR_INVALID_ARG;
+      return Cr.NS_ERROR_INVALID_ARG;
+    }
+
+    if (!this._scanningWrapTunerData) {
+      return aCallback.notifyError(Cr.NS_ERROR_DOM_INVALID_STATE_ERR);
+    }
+
+    let wrapTunerData = this._getWrapTunerData(aTunerId, aSourceType);
+    if (!wrapTunerData) {
+      return aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
     }
 
-    for (let listener of this._getSourceListeners(aTunerId, aSourceType)) {
-      listener.notifyChannelScanStopped(aTunerId, aSourceType);
+    if (this._scanCompleteTimer) {
+      this._scanCompleteTimer.cancel();
+      this._scanCompleteTimer = null;
     }
 
-    aCallback.notifySuccess(null);
+    if (wrapTunerData.tuner.id === this._scanningWrapTunerData.tuner.id &&
+        wrapTunerData.sourceType === this._scanningWrapTunerData.sourceType) {
+      this._scanningWrapTunerData = null;
+      this._sourceListener.notifyChannelScanStopped(
+                                 wrapTunerData.tuner.id,
+                                 wrapTunerData.sourceType);
+    }
+
+    return aCallback.notifySuccess(null);
   },
 
-  clearScannedChannelsCache: function(aTunerId, aSourceType, aCallback) {
-    // Simulator service doesn't support channel cache, so there's nothing to do here.
+  clearScannedChannelsCache: function TVSimClearScannedChannelsCache(aTunerId, aSourceType, aCallback) {
+    // Doesn't support for this method.
+    return Cr.NS_OK;
   },
 
-  setChannel: function(aTunerId, aSourceType, aChannelNumber, aCallback) {
+  setChannel: function TVSimSetChannel(aTunerId, aSourceType, aChannelNumber, aCallback) {
     if (!aCallback) {
       debug("aCallback is null\n");
-      throw Cr.NS_ERROR_INVALID_ARG;
+      return Cr.NS_ERROR_INVALID_ARG;
     }
 
     let channel = Cc["@mozilla.org/array;1"]
                     .createInstance(Ci.nsIMutableArray);
 
     let wrapTunerData = this._getWrapTunerData(aTunerId, aSourceType);
     if (!wrapTunerData || !wrapTunerData.channels) {
-      aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
-      return;
+      return aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
     }
 
     let wrapChannelData = wrapTunerData.channels.get(aChannelNumber);
     if (!wrapChannelData) {
-      aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
-      return;
+      return aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
     }
 
     channel.appendElement(wrapChannelData.channel, false);
-    aCallback.notifySuccess(channel);
+    return aCallback.notifySuccess(channel);
+
   },
 
-  getChannels: function(aTunerId, aSourceType, aCallback) {
+  getChannels: function TVSimGetChannels(aTunerId, aSourceType, aCallback) {
     if (!aCallback) {
       debug("aCallback is null\n");
-      throw Cr.NS_ERROR_INVALID_ARG;
+      return Cr.NS_ERROR_INVALID_ARG;
     }
 
     let channelArray = Cc["@mozilla.org/array;1"]
                          .createInstance(Ci.nsIMutableArray);
 
     let wrapTunerData = this._getWrapTunerData(aTunerId, aSourceType);
     if (!wrapTunerData || !wrapTunerData.channels) {
-      aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
-      return;
+      return aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
     }
 
     for (let [key, wrapChannelData] of wrapTunerData.channels) {
       channelArray.appendElement(wrapChannelData.channel, false);
     }
 
-    aCallback.notifySuccess(channelArray);
+    return aCallback.notifySuccess(channelArray);
   },
 
-  getPrograms: function(aTunerId, aSourceType, aChannelNumber, aStartTime, aEndTime, aCallback) {
+  getPrograms: function TVSimGetPrograms(aTunerId, aSourceType, aChannelNumber, aStartTime, aEndTime, aCallback) {
     if (!aCallback) {
       debug("aCallback is null\n");
-      throw Cr.NS_ERROR_INVALID_ARG;
+      return Cr.NS_ERROR_INVALID_ARG;
     }
     let programArray = Cc["@mozilla.org/array;1"]
                          .createInstance(Ci.nsIMutableArray);
 
     let wrapTunerData = this._getWrapTunerData(aTunerId, aSourceType);
     if (!wrapTunerData || !wrapTunerData.channels) {
-      aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
-      return;
+      return aCallback.notifyError(Ci.nsITVServiceCallback.TV_ERROR_FAILURE);
     }
 
     let wrapChannelData = wrapTunerData.channels.get(aChannelNumber);
     if (!wrapChannelData || !wrapChannelData.programs) {
-      throw Cr.NS_ERROR_INVALID_ARG;
+      return Cr.NS_ERROR_INVALID_ARG;
     }
 
     for (let program of wrapChannelData.programs) {
       programArray.appendElement(program, false);
     }
 
-    aCallback.notifySuccess(programArray);
+    return aCallback.notifySuccess(programArray);
+
   },
 
-  getSimulatorVideoBlobURL: function(aTunerId, aSourceType, aChannelNumber, aWin) {
+  getOverlayId: function TVSimGetOverlayId(aTunerId, aCallback) {
+    if (!aCallback) {
+      debug("aCallback is null\n");
+      return Cr.NS_ERROR_INVALID_ARG;
+    }
+
+    // TVSimulatorService does not use this parameter.
+    overlayIds = Cc["@mozilla.org/array;1"]
+                  .createInstance(Ci.nsIMutableArray);
+    return aCallback.notifySuccess(overlayIds);
+  },
+
+  set sourceListener(aListener) {
+    this._sourceListener = aListener;
+  },
+
+  get sourceListener() {
+      return this._sourceListener;
+  },
+
+  getSimulatorVideoBlobURL: function TVSimGetSimulatorVideoBlob(aTunerId,
+                                                                aSourceType,
+                                                                aChannelNumber,
+                                                                aWin) {
     let wrapTunerData = this._getWrapTunerData(aTunerId, aSourceType);
     if (!wrapTunerData || !wrapTunerData.channels) {
       return "";
     }
 
     let wrapChannelData = wrapTunerData.channels.get(aChannelNumber);
     if (!wrapChannelData || !wrapChannelData.videoFilePath) {
       return "";
     }
 
     let videoFile = new File(this._getFilePath(wrapChannelData.videoFilePath));
     let videoBlobURL = aWin.URL.createObjectURL(videoFile);
 
     return videoBlobURL;
   },
 
-  simulateChannelScanned: function(aTunerId, aSourceType) {
-    let wrapTunerData = this._getWrapTunerData(aTunerId, aSourceType);
-    if (!wrapTunerData || !wrapTunerData.channels) {
-      throw Cr.NS_ERROR_INVALID_ARG;
-    }
-
-    let listeners = this._getSourceListeners(aTunerId, aSourceType);
-    for (let [key, wrapChannelData] of wrapTunerData.channels) {
-      for (let listener of listeners) {
-        listener.notifyChannelScanned(aTunerId, aSourceType, wrapChannelData.channel);
-      }
-    }
-  },
-
-  simulateChannelScanComplete: function(aTunerId, aSourceType) {
-    for (let listener of this._getSourceListeners(aTunerId, aSourceType)) {
-      listener.notifyChannelScanComplete(aTunerId, aSourceType);
-    }
-  },
-
-  simulateChannelScanError: function(aTunerId, aSourceType) {
-    for (let listener of this._getSourceListeners(aTunerId, aSourceType)) {
-      listener.notifyChannelScanStopped(aTunerId, aSourceType);
-    }
-  },
-
-  simulateEITBroadcasted: function(aTunerId, aSourceType, aChannelNumber) {
-    let wrapTunerData = this._getWrapTunerData(aTunerId, aSourceType);
-    if (!wrapTunerData || !wrapTunerData.channels) {
-      throw Cr.NS_ERROR_INVALID_ARG;
-    }
-
-    let wrapChannelData = wrapTunerData.channels.get(aChannelNumber);
-    if (!wrapChannelData || !wrapChannelData.programs) {
-      throw Cr.NS_ERROR_INVALID_ARG;
-    }
-
-    for (let listener of this._getSourceListeners(aTunerId, aSourceType)) {
-      listener.notifyEITBroadcasted(aTunerId, aSourceType,
-                                    wrapChannelData.channel,
-                                    wrapChannelData.programs,
-                                    wrapChannelData.programs.length);
-    }
-  },
-
-  _getDummyData : function() {
+  _getDummyData : function TVSimGetDummyData() {
     // Load the setting file from local JSON file.
     // Synchrhronous File Reading.
     let file = Cc["@mozilla.org/file/local;1"]
                  .createInstance(Ci.nsILocalFile);
 
     let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
                     .createInstance(Ci.nsIFileInputStream);
     let cstream = Cc["@mozilla.org/intl/converter-input-stream;1"]
@@ -484,42 +449,42 @@ TVSimulatorService.prototype = {
       throw e;
     } finally {
       cstream.close();
     }
 
     return settingsStr;
   },
 
-  _getTunerMapKey: function(aTunerId, aSourceType) {
+  _getTunerMapKey: function TVSimGetTunerMapKey(aTunerId, aSourceType) {
     return JSON.stringify({'tunerId': aTunerId, 'sourceType': aSourceType});
   },
 
-  _getWrapTunerData: function(aTunerId, aSourceType) {
+  _getWrapTunerData: function TVSimGetWrapTunerData(aTunerId, aSourceType) {
     if (!this._internalTuners || this._internalTuners.size <= 0) {
       return null;
     }
     return this._internalTuners.get(this._getTunerMapKey(aTunerId, aSourceType));
   },
 
-  _getFilePath: function(fileName) {
+  _getFilePath: function TVSimGetFilePathFromDummyDirectory(fileName) {
     let dsFile = Cc["@mozilla.org/file/directory_service;1"]
                    .getService(Ci.nsIProperties)
                    .get("ProfD", Ci.nsIFile);
     dsFile.append(TV_SIMULATOR_DUMMY_DIRECTORY);
     dsFile.append(fileName);
 
     return dsFile.path;
   },
 
-  _validateSettings: function(aSettingsObject) {
+  _validateSettings: function TVSimValidateSettings(aSettingsObject) {
     return this._validateTuners(aSettingsObject.tuners);
   },
 
-  _validateTuners: function(aTunersObject) {
+  _validateTuners: function TVSimValidateTuners(aTunersObject) {
     let tunerIds = new Array();
     for (let tuner of aTunersObject) {
       if (!tuner.id ||
           !tuner.supportedType ||
           !tuner.supportedType.length ||
           tuner.supportedType.some(containInvalidSourceType) ||
           tunerIds.includes(tuner.id)) {
         debug("invalid tuner data.");
@@ -529,32 +494,32 @@ TVSimulatorService.prototype = {
 
       if (!this._validateSources(tuner.sources)) {
         return false;
       }
     }
     return true;
   },
 
-  _validateSources: function(aSourcesObject) {
+  _validateSources: function TVSimValidateSources(aSourcesObject) {
     for (let source of aSourcesObject) {
       if (!source.type ||
           !TV_SOURCE_TYPES.includes(source.type)) {
         debug("invalid source data.");
         return false;
       }
 
       if (!this._validateChannels(source.channels)) {
         return false;
       }
     }
     return true;
   },
 
-  _validateChannels: function(aChannelsObject) {
+  _validateChannels: function TVSimValidateChannels(aChannelsObject) {
     let channelNumbers = new Array();
     for (let channel of aChannelsObject) {
       if (!channel.networkId ||
           !channel.transportStreamId ||
           !channel.serviceId ||
           !channel.type ||
           !TV_CHANNEL_TYPES.includes(channel.type) ||
           !channel.number ||
@@ -567,17 +532,17 @@ TVSimulatorService.prototype = {
 
       if (!this._validatePrograms(channel.programs)) {
         return false;
       }
     }
     return true;
   },
 
-  _validatePrograms: function(aProgramsObject) {
+  _validatePrograms: function TVSimValidatePrograms(aProgramsObject) {
     let eventIds = new Array();
     for (let program of aProgramsObject) {
       if (!program.eventId ||
           eventIds.includes(program.eventId) ||
           !program.title ||
           !program.startTime ||
           !program.duration) {
         debug("invalid program data.");
--- a/dom/tv/TVSource.cpp
+++ b/dom/tv/TVSource.cpp
@@ -16,18 +16,32 @@
 #include "mozilla/dom/TVUtils.h"
 #include "nsITVService.h"
 #include "nsServiceManagerUtils.h"
 #include "TVSource.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(TVSource, DOMEventTargetHelper, mTuner,
-                                   mCurrentChannel, mSourceListener)
+NS_IMPL_CYCLE_COLLECTION_CLASS(TVSource)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(TVSource,
+                                                  DOMEventTargetHelper)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTVService)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTuner)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCurrentChannel)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(TVSource,
+                                                DOMEventTargetHelper)
+  tmp->Shutdown();
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mTVService)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mTuner)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mCurrentChannel)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_ADDREF_INHERITED(TVSource, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(TVSource, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TVSource)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 TVSource::TVSource(nsPIDOMWindowInner* aWindow,
@@ -38,36 +52,55 @@ TVSource::TVSource(nsPIDOMWindowInner* a
   , mType(aType)
   , mIsScanning(false)
 {
   MOZ_ASSERT(mTuner);
 }
 
 TVSource::~TVSource()
 {
+  Shutdown();
 }
 
 /* static */ already_AddRefed<TVSource>
 TVSource::Create(nsPIDOMWindowInner* aWindow,
                  TVSourceType aType,
                  TVTuner* aTuner)
 {
   RefPtr<TVSource> source = new TVSource(aWindow, aType, aTuner);
   return (source->Init()) ? source.forget() : nullptr;
 }
 
 bool
 TVSource::Init()
 {
-  mSourceListener = TVSourceListener::Create(this);
-  if (NS_WARN_IF(!mSourceListener)) {
-    return false;
+  mTVService = TVServiceFactory::AutoCreateTVService();
+  NS_ENSURE_TRUE(mTVService, false);
+
+  nsCOMPtr<nsITVSourceListener> sourceListener;
+  mTVService->GetSourceListener(getter_AddRefs(sourceListener));
+  NS_ENSURE_TRUE(sourceListener, false);
+  (static_cast<TVSourceListener*>(sourceListener.get()))->RegisterSource(this);
+
+  return true;
+}
+
+void
+TVSource::Shutdown()
+{
+  if (!mTVService) {
+    return;
   }
 
-  return true;
+  nsCOMPtr<nsITVSourceListener> sourceListener;
+  mTVService->GetSourceListener(getter_AddRefs(sourceListener));
+  if (!sourceListener) {
+    return;
+  }
+  (static_cast<TVSourceListener*>(sourceListener.get()))->UnregisterSource(this);
 }
 
 /* virtual */ JSObject*
 TVSource::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return TVSourceBinding::Wrap(aCx, this, aGivenProto);
 }
 
@@ -142,29 +175,23 @@ TVSource::GetChannels(ErrorResult& aRv)
   }
 
   // The operation is prohibited when the source is scanning channels.
   if (mIsScanning) {
     promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
     return promise.forget();
   }
 
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-    return promise.forget();
-  }
-
   nsString tunerId;
   mTuner->GetId(tunerId);
 
   nsCOMPtr<nsITVServiceCallback> callback =
     new TVServiceChannelGetterCallback(this, promise);
   nsresult rv =
-    service->GetChannels(tunerId, ToTVSourceTypeStr(mType), callback);
+    mTVService->GetChannels(tunerId, ToTVSourceTypeStr(mType), callback);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
   }
 
   return promise.forget();
 }
 
 already_AddRefed<Promise>
@@ -180,29 +207,23 @@ TVSource::SetCurrentChannel(const nsAStr
   }
 
   // The operation is prohibited when the source is scanning channels.
   if (mIsScanning) {
     promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
     return promise.forget();
   }
 
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-    return promise.forget();
-  }
-
   nsString tunerId;
   mTuner->GetId(tunerId);
 
   nsCOMPtr<nsITVServiceCallback> callback =
     new TVServiceChannelSetterCallback(this, promise, aChannelNumber);
-  nsresult rv = service->SetChannel(tunerId, ToTVSourceTypeStr(mType),
-                                    aChannelNumber, callback);
+  nsresult rv =
+    mTVService->SetChannel(tunerId, ToTVSourceTypeStr(mType), aChannelNumber, callback);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
   }
 
   return promise.forget();
 }
 
 already_AddRefed<Promise>
@@ -212,48 +233,42 @@ TVSource::StartScanning(const TVStartSca
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
   MOZ_ASSERT(global);
 
   RefPtr<Promise> promise = Promise::Create(global, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-    return promise.forget();
-  }
+  nsString tunerId;
+  mTuner->GetId(tunerId);
 
   bool isRescanned = aOptions.mIsRescanned.WasPassed() &&
                      aOptions.mIsRescanned.Value();
 
   if (isRescanned) {
-    nsresult rv = service->ClearScannedChannelsCache();
+    nsresult rv = mTVService->ClearScannedChannelsCache();
     if (NS_WARN_IF(NS_FAILED(rv))) {
       promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
       return promise.forget();
     }
 
     rv = DispatchScanningStateChangedEvent(TVScanningState::Cleared, nullptr);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
       return promise.forget();
     }
   }
 
-  nsString tunerId;
-  mTuner->GetId(tunerId);
-
   // |SetIsScanning(bool)| should be called once |notifySuccess()| of this
   // callback is invoked.
   nsCOMPtr<nsITVServiceCallback> callback =
     new TVServiceChannelScanCallback(this, promise, true);
   nsresult rv =
-    service->StartScanningChannels(tunerId, ToTVSourceTypeStr(mType), callback);
+    mTVService->StartScanningChannels(tunerId, ToTVSourceTypeStr(mType), callback);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
   }
 
   return promise.forget();
 }
 
 already_AddRefed<Promise>
@@ -262,31 +277,25 @@ TVSource::StopScanning(ErrorResult& aRv)
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
   MOZ_ASSERT(global);
 
   RefPtr<Promise> promise = Promise::Create(global, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-    return promise.forget();
-  }
-
   nsString tunerId;
   mTuner->GetId(tunerId);
 
   // |SetIsScanning(bool)| should be called once |notifySuccess()| of this
   // callback is invoked.
   nsCOMPtr<nsITVServiceCallback> callback =
     new TVServiceChannelScanCallback(this, promise, false);
   nsresult rv =
-    service->StopScanningChannels(tunerId, ToTVSourceTypeStr(mType), callback);
+    mTVService->StopScanningChannels(tunerId, ToTVSourceTypeStr(mType), callback);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
   }
 
   return promise.forget();
 }
 
 already_AddRefed<TVTuner>
--- a/dom/tv/TVSource.h
+++ b/dom/tv/TVSource.h
@@ -11,17 +11,17 @@
 // Include TVScanningStateChangedEventBinding.h since enum TVScanningState can't
 // be forward declared.
 #include "mozilla/dom/TVScanningStateChangedEventBinding.h"
 // Include TVSourceBinding.h since enum TVSourceType can't be forward declared.
 #include "mozilla/dom/TVSourceBinding.h"
 
 class nsITVChannelData;
 class nsITVProgramData;
-class nsITVSourceListener;
+class nsITVService;
 
 namespace mozilla {
 namespace dom {
 
 class Promise;
 class TVChannel;
 class TVProgram;
 class TVTuner;
@@ -87,26 +87,28 @@ private:
   TVSource(nsPIDOMWindowInner* aWindow,
            TVSourceType aType,
            TVTuner* aTuner);
 
   ~TVSource();
 
   bool Init();
 
+  void Shutdown();
+
   nsresult DispatchCurrentChannelChangedEvent(TVChannel* aChannel);
 
   nsresult DispatchScanningStateChangedEvent(TVScanningState aState,
                                              TVChannel* aChannel);
 
   nsresult DispatchEITBroadcastedEvent(const Sequence<OwningNonNull<TVProgram>>& aPrograms);
 
+  nsCOMPtr<nsITVService> mTVService;
   RefPtr<TVTuner> mTuner;
   RefPtr<TVChannel> mCurrentChannel;
-  nsCOMPtr<nsITVSourceListener> mSourceListener;
   TVSourceType mType;
   bool mIsScanning;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_TVSource_h
--- a/dom/tv/TVTuner.cpp
+++ b/dom/tv/TVTuner.cpp
@@ -1,34 +1,33 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "TVTuner.h"
-
 #include "DOMMediaStream.h"
-#include "mozilla/dom/HTMLVideoElement.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/TVCurrentSourceChangedEvent.h"
 #include "mozilla/dom/TVServiceCallbacks.h"
 #include "mozilla/dom/TVServiceFactory.h"
 #include "mozilla/dom/TVSource.h"
 #include "mozilla/dom/TVUtils.h"
 #include "nsISupportsPrimitives.h"
 #include "nsITVService.h"
 #include "nsITVSimulatorService.h"
 #include "nsServiceManagerUtils.h"
+#include "TVTuner.h"
+#include "mozilla/dom/HTMLVideoElement.h"
 
 namespace mozilla {
 namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED(TVTuner, DOMEventTargetHelper, mStream,
-                                   mCurrentSource, mSources)
+NS_IMPL_CYCLE_COLLECTION_INHERITED(TVTuner, DOMEventTargetHelper,
+                                   mTVService, mStream, mCurrentSource, mSources)
 
 NS_IMPL_ADDREF_INHERITED(TVTuner, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(TVTuner, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TVTuner)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 TVTuner::TVTuner(nsPIDOMWindowInner* aWindow)
@@ -77,32 +76,35 @@ TVTuner::Init(nsITVTunerData* aData)
       continue;
     }
 
     mSupportedSourceTypes.AppendElement(sourceType);
     mSources.AppendElement(source);
   }
   NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, supportedSourceTypes);
 
+  mTVService = TVServiceFactory::AutoCreateTVService();
+  NS_ENSURE_TRUE(mTVService, false);
+
   rv = aData->GetStreamType(&mStreamType);
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 /* virtual */ JSObject*
 TVTuner::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return TVTunerBinding::Wrap(aCx, this, aGivenProto);
 }
 
 nsresult
-TVTuner::SetCurrentSource(TVSourceType aSourceType,
-                          nsITVGonkNativeHandleData* aHandleData)
+TVTuner::SetCurrentSource(TVSourceType aSourceType)
 {
+  ErrorResult error;
   if (mCurrentSource) {
     if (aSourceType == mCurrentSource->Type()) {
       // No actual change.
       return NS_OK;
     }
 
     // No need to stay tuned for non-current sources.
     nsresult rv = mCurrentSource->UnsetCurrentChannel();
@@ -113,17 +115,20 @@ TVTuner::SetCurrentSource(TVSourceType a
 
   for (uint32_t i = 0; i < mSources.Length(); i++) {
     if (aSourceType == mSources[i]->Type()) {
       mCurrentSource = mSources[i];
       break;
     }
   }
 
-  mStream = CreateHwMediaStream(aHandleData);
+  nsresult rv = InitMediaStream();
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
 
   return DispatchCurrentSourceChangedEvent(mCurrentSource);
 }
 
 nsresult
 TVTuner::DispatchTVEvent(nsIDOMEvent* aEvent)
 {
   return DispatchTrustedEvent(aEvent);
@@ -158,29 +163,21 @@ TVTuner::SetCurrentSource(const TVSource
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
   MOZ_ASSERT(global);
 
   RefPtr<Promise> promise = Promise::Create(global, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  if (NS_WARN_IF(!service)) {
-    promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
-  }
-
-  // For TV simulator, |SetCurrentSource(TVSourceType)| will be called once
-  // |notifySuccess| of the callback is invoked. On the other hand, for gonk TV,
-  // |SetCurrentSource(TVSourceType, const GonkNativeHandle&)| will be called
-  // once |notifyStreamHandle| of the callback is invoked.
+  // |SetCurrentSource(const TVSourceType)| will be called once |notifySuccess|
+  // of the callback is invoked.
   nsCOMPtr<nsITVServiceCallback> callback =
     new TVServiceSourceSetterCallback(this, promise, aSourceType);
-  nsresult rv =
-    service->SetSource(mId, ToTVSourceTypeStr(aSourceType), callback);
+  nsresult rv = mTVService->SetSource(mId, ToTVSourceTypeStr(aSourceType), callback);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
   }
 
   return promise.forget();
 }
 
 void
@@ -201,53 +198,32 @@ TVTuner::GetStream() const
 {
   RefPtr<DOMMediaStream> stream = mStream;
   return stream.forget();
 }
 
 nsresult
 TVTuner::ReloadMediaStream()
 {
-  // Only TV simulator needs to reload the media stream (during channel changes).
-  if (NS_WARN_IF(nsITVTunerData::TV_STREAM_TYPE_SIMULATOR != mStreamType)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  mStream = CreateSimulatedMediaStream();
-
-  return NS_OK;
+  return InitMediaStream();
 }
 
-already_AddRefed<DOMMediaStream>
-TVTuner::CreateHwMediaStream(nsITVGonkNativeHandleData* aHandleData)
+nsresult
+TVTuner::InitMediaStream()
 {
-  RefPtr<DOMMediaStream> stream;
-
+  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
+  RefPtr<DOMMediaStream> stream = nullptr;
   if (mStreamType == nsITVTunerData::TV_STREAM_TYPE_HW) {
-#ifdef MOZ_WIDGET_GONK
-    nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-
-    layers::OverlayImage::SidebandStreamData imageData;
-    aHandleData->GetHandle(imageData.mStream);
-    window->GetInnerWidth(&imageData.mSize.width);
-    window->GetInnerHeight(&imageData.mSize.height);
-
-    RefPtr<layers::OverlayImage> overlayImage = new layers::OverlayImage();
-    overlayImage->SetData(imageData);
-    stream = DOMHwMediaStream::CreateHwStream(window, overlayImage);
-#endif
+    stream = DOMHwMediaStream::CreateHwStream(window);
   } else if (mStreamType == nsITVTunerData::TV_STREAM_TYPE_SIMULATOR) {
     stream = CreateSimulatedMediaStream();
   }
 
-  if (NS_WARN_IF(!stream)) {
-    return nullptr;
-  }
-
-  return stream.forget();
+  mStream = stream.forget();
+  return NS_OK;
 }
 
 already_AddRefed<DOMMediaStream>
 TVTuner::CreateSimulatedMediaStream()
 {
   nsCOMPtr<nsPIDOMWindowInner> domWin = GetOwner();
   if (NS_WARN_IF(!domWin)) {
     return nullptr;
@@ -279,20 +255,17 @@ TVTuner::CreateSimulatedMediaStream()
     return nullptr;
   }
 
   mediaElement->SetLoop(true, error);
   if (NS_WARN_IF(error.Failed())) {
     return nullptr;
   }
 
-  nsCOMPtr<nsITVService> service = do_GetService(TV_SERVICE_CONTRACTID);
-  MOZ_ASSERT(service);
-
-  nsCOMPtr<nsITVSimulatorService> simService(do_QueryInterface(service));
+  nsCOMPtr<nsITVSimulatorService> simService(do_QueryInterface(mTVService));
   if (NS_WARN_IF(!simService)) {
     return nullptr;
   }
 
   if (NS_WARN_IF(!mCurrentSource)) {
     return nullptr;
   }
 
--- a/dom/tv/TVTuner.h
+++ b/dom/tv/TVTuner.h
@@ -8,17 +8,17 @@
 #define mozilla_dom_TVTuner_h
 
 #include "mozilla/DOMEventTargetHelper.h"
 // Include TVTunerBinding.h since enum TVSourceType can't be forward declared.
 #include "mozilla/dom/TVTunerBinding.h"
 
 #define VIDEO_TAG NS_LITERAL_STRING("video")
 
-class nsITVGonkNativeHandleData;
+class nsITVService;
 class nsITVTunerData;
 
 namespace mozilla {
 
 class DOMMediaStream;
 
 namespace dom {
 
@@ -28,25 +28,23 @@ class TVSource;
 class TVTuner final : public DOMEventTargetHelper
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TVTuner, DOMEventTargetHelper)
 
   static already_AddRefed<TVTuner> Create(nsPIDOMWindowInner* aWindow,
                                           nsITVTunerData* aData);
-
   nsresult NotifyImageSizeChanged(uint32_t aWidth, uint32_t aHeight);
 
   // WebIDL (internal functions)
 
   virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
-  nsresult SetCurrentSource(TVSourceType aSourceType,
-                            nsITVGonkNativeHandleData* aHandleData);
+  nsresult SetCurrentSource(TVSourceType aSourceType);
 
   nsresult DispatchTVEvent(nsIDOMEvent* aEvent);
 
   // WebIDL (public APIs)
 
   void GetSupportedSourceTypes(nsTArray<TVSourceType>& aSourceTypes,
                                ErrorResult& aRv) const;
 
@@ -69,23 +67,21 @@ private:
   explicit TVTuner(nsPIDOMWindowInner* aWindow);
 
   ~TVTuner();
 
   bool Init(nsITVTunerData* aData);
 
   nsresult InitMediaStream();
 
-  already_AddRefed<DOMMediaStream> CreateHwMediaStream(
-    nsITVGonkNativeHandleData* aHandleData);
-
   already_AddRefed<DOMMediaStream> CreateSimulatedMediaStream();
 
   nsresult DispatchCurrentSourceChangedEvent(TVSource* aSource);
 
+  nsCOMPtr<nsITVService> mTVService;
   RefPtr<DOMMediaStream> mStream;
   uint16_t mStreamType;
   RefPtr<TVSource> mCurrentSource;
   nsTArray<RefPtr<TVSource>> mSources;
   nsString mId;
   nsTArray<TVSourceType> mSupportedSourceTypes;
 };
 
--- a/dom/tv/TVTypes.cpp
+++ b/dom/tv/TVTypes.cpp
@@ -76,29 +76,18 @@ TVTunerData::GetSupportedSourceTypes(uin
     sourceTypes[i] = NS_strdup(mSupportedSourceTypes[i]);
   }
 
   *aSourceTypes = sourceTypes;
   return NS_OK;
 }
 
 /* virtual */ NS_IMETHODIMP
-TVTunerData::GetSupportedSourceTypesByString(nsTArray<nsCString> & aSourceTypes)
-{
-  for (uint32_t i = 0; i < mCount; i++) {
-    nsCString sourceType;
-    sourceType.AssignASCII(mSupportedSourceTypes[i]);
-    aSourceTypes.AppendElement(sourceType);
-  }
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVTunerData::SetSupportedSourceTypes(uint32_t aCount, const char** aSourceTypes)
+TVTunerData::SetSupportedSourceTypes(uint32_t aCount,
+                                     const char** aSourceTypes)
 {
   if (aCount == 0) {
     return NS_ERROR_INVALID_ARG;
   }
   NS_ENSURE_ARG_POINTER(aSourceTypes);
 
   for (uint32_t i = 0; i < aCount; i++) {
     if (TVSourceType::EndGuard_ == ToTVSourceType(aSourceTypes[i])) {
@@ -117,49 +106,16 @@ TVTunerData::SetSupportedSourceTypes(uin
                           nullptr;
   for (uint32_t i = 0; i < mCount; i++) {
     mSupportedSourceTypes[i] = NS_strdup(aSourceTypes[i]);
   }
 
   return NS_OK;
 }
 
-/* virtual */ NS_IMETHODIMP
-TVTunerData::SetSupportedSourceTypesByString(
-  const nsTArray<nsCString>& aSourceTypes)
-{
-  uint32_t count = aSourceTypes.Length();
-
-  if (count == 0) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  for (uint32_t i = 0; i < count; i++) {
-    if (TVSourceType::EndGuard_ ==
-        ToTVSourceType(NS_ConvertUTF8toUTF16(aSourceTypes[i]))) {
-
-      return NS_ERROR_INVALID_ARG;
-    }
-  }
-
-  if (mSupportedSourceTypes) {
-    NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mCount, mSupportedSourceTypes);
-  }
-
-  mCount = count;
-
-  mSupportedSourceTypes =
-    (mCount > 0) ? static_cast<char**>(moz_xmalloc(mCount * sizeof(char*)))
-                 : nullptr;
-  for (uint32_t i = 0; i < mCount; i++) {
-    mSupportedSourceTypes[i] = NS_strdup(aSourceTypes[i].get());
-  }
-
-  return NS_OK;
-}
 
 /*
  * Implementation of TVChannelData
  */
 
 NS_IMPL_ISUPPORTS(TVChannelData, nsITVChannelData)
 
 TVChannelData::TVChannelData()
@@ -444,29 +400,18 @@ TVProgramData::GetAudioLanguages(uint32_
     languages[i] = NS_strdup(mAudioLanguages[i]);
   }
 
   *aLanguages = languages;
   return NS_OK;
 }
 
 /* virtual */ NS_IMETHODIMP
-TVProgramData::GetAudioLanguagesByString(nsTArray<nsCString>& aLanguages)
-{
-  for (uint32_t i = 0; i < mAudioLanguageCount; i++) {
-    nsCString languages;
-    languages.AssignASCII(mAudioLanguages[i]);
-    aLanguages.AppendElement(languages);
-  }
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVProgramData::SetAudioLanguages(uint32_t aCount, const char** aLanguages)
+TVProgramData::SetAudioLanguages(uint32_t aCount,
+                                 const char** aLanguages)
 {
   if (aCount > 0) {
     NS_ENSURE_ARG_POINTER(aLanguages);
   }
 
   if (mAudioLanguages) {
     NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mAudioLanguageCount, mAudioLanguages);
   }
@@ -479,122 +424,50 @@ TVProgramData::SetAudioLanguages(uint32_
   for (uint32_t i = 0; i < mAudioLanguageCount; i++) {
     mAudioLanguages[i] = NS_strdup(aLanguages[i]);
   }
 
   return NS_OK;
 }
 
 /* virtual */ NS_IMETHODIMP
-TVProgramData::SetAudioLanguagesByString(const nsTArray<nsCString>& aLanguages)
-{
-  if (mAudioLanguages) {
-    NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mAudioLanguageCount, mAudioLanguages);
-  }
-
-  mAudioLanguageCount = aLanguages.Length();
-
-  mAudioLanguages =
-    (mAudioLanguageCount > 0)
-      ? static_cast<char**>(moz_xmalloc(mAudioLanguageCount * sizeof(char*)))
-      : nullptr;
-  for (uint32_t i = 0; i < mAudioLanguageCount; i++) {
-    mAudioLanguages[i] = NS_strdup(aLanguages[i].get());
-  }
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVProgramData::GetSubtitleLanguages(uint32_t* aCount, char*** aLanguages)
+TVProgramData::GetSubtitleLanguages(uint32_t* aCount,
+                                    char*** aLanguages)
 {
   *aCount = mSubtitleLanguageCount;
 
   char** languages = (mSubtitleLanguageCount > 0) ?
                      static_cast<char **>(moz_xmalloc(mSubtitleLanguageCount * sizeof(char*))) :
                      nullptr;
   for (uint32_t i = 0; i < mSubtitleLanguageCount; i++) {
     languages[i] = NS_strdup(mSubtitleLanguages[i]);
   }
 
   *aLanguages = languages;
   return NS_OK;
 }
 
 /* virtual */ NS_IMETHODIMP
-TVProgramData::GetSubtitleLanguagesByString(nsTArray<nsCString>& aLanguages)
+TVProgramData::SetSubtitleLanguages(uint32_t aCount,
+                                    const char** aLanguages)
 {
-  for (uint32_t i = 0; i < mSubtitleLanguageCount; i++) {
-    nsCString languages;
-    languages.AssignASCII(mSubtitleLanguages[i]);
-    aLanguages.AppendElement(languages);
+  if (aCount > 0) {
+    NS_ENSURE_ARG_POINTER(aLanguages);
   }
 
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVProgramData::SetSubtitleLanguages(uint32_t aCount, const char** aLanguages)
-{
   if (mSubtitleLanguages) {
     NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mSubtitleLanguageCount, mSubtitleLanguages);
   }
 
   mSubtitleLanguageCount = aCount;
 
   mSubtitleLanguages = (mSubtitleLanguageCount > 0) ?
                        static_cast<char **>(moz_xmalloc(mSubtitleLanguageCount * sizeof(char*))) :
                        nullptr;
   for (uint32_t i = 0; i < mSubtitleLanguageCount; i++) {
     mSubtitleLanguages[i] = NS_strdup(aLanguages[i]);
   }
 
   return NS_OK;
 }
 
-/* virtual */ NS_IMETHODIMP
-TVProgramData::SetSubtitleLanguagesByString(
-  const nsTArray<nsCString>& aLanguages)
-{
-  if (mSubtitleLanguages) {
-    NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mSubtitleLanguageCount,
-                                          mSubtitleLanguages);
-  }
-
-  mSubtitleLanguageCount = aLanguages.Length();
-
-  mSubtitleLanguages =
-    (mSubtitleLanguageCount > 0)
-      ? static_cast<char**>(moz_xmalloc(mSubtitleLanguageCount * sizeof(char*)))
-      : nullptr;
-  for (uint32_t i = 0; i < mSubtitleLanguageCount; i++) {
-    mSubtitleLanguages[i] = NS_strdup(aLanguages[i].get());
-  }
-
-  return NS_OK;
-}
-
-/*
- * Implementation of TVGonkNativeHandleData
- */
-
-NS_IMPL_ISUPPORTS(TVGonkNativeHandleData, nsITVGonkNativeHandleData)
-
-TVGonkNativeHandleData::TVGonkNativeHandleData() {}
-
-TVGonkNativeHandleData::~TVGonkNativeHandleData() {}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkNativeHandleData::GetHandle(GonkNativeHandle& aHandle)
-{
-  aHandle = mHandle;
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkNativeHandleData::SetHandle(GonkNativeHandle& aHandle)
-{
-  mHandle = aHandle;
-  return NS_OK;
-}
-
 } // namespace dom
 } // namespace mozilla
--- a/dom/tv/TVTypes.h
+++ b/dom/tv/TVTypes.h
@@ -2,50 +2,42 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_TVTypes_h
 #define mozilla_dom_TVTypes_h
 
-#include "mozilla/dom/PTVTypes.h"
-#include "mozilla/layers/GonkNativeHandle.h"
-#include "mozilla/Tuple.h"
 #include "nsITVService.h"
 
 namespace mozilla {
 namespace dom {
 
-typedef Tuple<nsString, nsString, nsCOMPtr<nsITVSourceListener>>
-TVSourceListenerTuple;
-
-using mozilla::layers::GonkNativeHandle;
-
 class TVTunerData final : public nsITVTunerData
 {
 public:
-  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_ISUPPORTS
   NS_DECL_NSITVTUNERDATA
 
   TVTunerData();
 
 private:
   ~TVTunerData();
 
   nsString mId;
   char** mSupportedSourceTypes;
   uint32_t mCount;
   uint16_t mStreamType;
 };
 
 class TVChannelData final : public nsITVChannelData
 {
 public:
-  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_ISUPPORTS
   NS_DECL_NSITVCHANNELDATA
 
   TVChannelData();
 
 private:
   ~TVChannelData();
 
   nsString mNetworkId;
@@ -56,17 +48,17 @@ private:
   nsString mName;
   bool mIsEmergency;
   bool mIsFree;
 };
 
 class TVProgramData final : public nsITVProgramData
 {
 public:
-  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_ISUPPORTS
   NS_DECL_NSITVPROGRAMDATA
 
   TVProgramData();
 
 private:
   ~TVProgramData();
 
   nsString mEventId;
@@ -76,26 +68,12 @@ private:
   nsString mDescription;
   nsString mRating;
   char** mAudioLanguages;
   uint32_t mAudioLanguageCount;
   char** mSubtitleLanguages;
   uint32_t mSubtitleLanguageCount;
 };
 
-class TVGonkNativeHandleData final : public nsITVGonkNativeHandleData
-{
-public:
-  NS_DECL_THREADSAFE_ISUPPORTS
-  NS_DECL_NSITVGONKNATIVEHANDLEDATA
-
-  TVGonkNativeHandleData();
-
-private:
-  ~TVGonkNativeHandleData();
-
-  GonkNativeHandle mHandle;
-};
-
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_TVTypes_h
deleted file mode 100644
--- a/dom/tv/gonk/TVGonkService.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TVGonkService.h"
-
-#include "mozilla/dom/TVServiceRunnables.h"
-#include "nsCOMPtr.h"
-#include "nsIMutableArray.h"
-#include "nsServiceManagerUtils.h"
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_ISUPPORTS(TVGonkService, nsITVService)
-
-TVGonkService::TVGonkService() {}
-
-TVGonkService::~TVGonkService() {}
-
-NS_IMETHODIMP
-TVGonkService::RegisterSourceListener(const nsAString& aTunerId,
-                                      const nsAString& aSourceType,
-                                      nsITVSourceListener* aListener)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(aListener);
-
-  mSourceListenerTuples.AppendElement(new TVSourceListenerTuple(
-    nsString(aTunerId), nsString(aSourceType), aListener));
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-TVGonkService::UnregisterSourceListener(const nsAString& aTunerId,
-                                        const nsAString& aSourceType,
-                                        nsITVSourceListener* aListener)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(aListener);
-
-  for (uint32_t i = 0; i < mSourceListenerTuples.Length(); i++) {
-    const UniquePtr<TVSourceListenerTuple>& tuple = mSourceListenerTuples[i];
-    if (aTunerId.Equals(Get<0>(*tuple)) && aSourceType.Equals(Get<1>(*tuple)) &&
-        aListener == Get<2>(*tuple)) {
-      mSourceListenerTuples.RemoveElementAt(i);
-      break;
-    }
-  }
-
-  return NS_OK;
-}
-
-void
-TVGonkService::GetSourceListeners(
-  const nsAString& aTunerId, const nsAString& aSourceType,
-  nsTArray<nsCOMPtr<nsITVSourceListener> >& aListeners) const
-{
-  aListeners.Clear();
-
-  for (uint32_t i = 0; i < mSourceListenerTuples.Length(); i++) {
-    const UniquePtr<TVSourceListenerTuple>& tuple = mSourceListenerTuples[i];
-    nsCOMPtr<nsITVSourceListener> listener = Get<2>(*tuple);
-    if (aTunerId.Equals(Get<0>(*tuple)) && aSourceType.Equals(Get<1>(*tuple))) {
-      aListeners.AppendElement(listener);
-      break;
-    }
-  }
-}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkService::GetTuners(nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(aCallback);
-
-  // TODO Bug 1229308 - Communicate with TV daemon process.
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkService::SetSource(const nsAString& aTunerId,
-                         const nsAString& aSourceType,
-                         nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(aCallback);
-
-  // TODO Bug 1229308 - Communicate with TV daemon process.
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkService::StartScanningChannels(const nsAString& aTunerId,
-                                     const nsAString& aSourceType,
-                                     nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(aCallback);
-
-  // TODO Bug 1229308 - Communicate with TV daemon process.
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkService::StopScanningChannels(const nsAString& aTunerId,
-                                    const nsAString& aSourceType,
-                                    nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(aCallback);
-
-  // TODO Bug 1229308 - Communicate with TV daemon process.
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkService::ClearScannedChannelsCache()
-{
-  // TODO Bug 1229308 - Communicate with TV daemon process.
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkService::SetChannel(const nsAString& aTunerId,
-                          const nsAString& aSourceType,
-                          const nsAString& aChannelNumber,
-                          nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(aCallback);
-
-  // TODO Bug 1229308 - Communicate with TV daemon process.
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkService::GetChannels(const nsAString& aTunerId,
-                           const nsAString& aSourceType,
-                           nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(aCallback);
-
-  // TODO Bug 1229308 - Communicate with TV daemon process.
-
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVGonkService::GetPrograms(const nsAString& aTunerId,
-                           const nsAString& aSourceType,
-                           const nsAString& aChannelNumber, uint64_t startTime,
-                           uint64_t endTime, nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(!aChannelNumber.IsEmpty());
-  MOZ_ASSERT(aCallback);
-
-  // TODO Bug 1229308 - Communicate with TV daemon process.
-
-  return NS_OK;
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/tv/gonk/TVGonkService.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_TVGonkService_h
-#define mozilla_dom_TVGonkService_h
-
-#include "nsCOMPtr.h"
-#include "nsITVService.h"
-#include "nsTArray.h"
-#include "TVTypes.h"
-
-namespace mozilla {
-namespace dom {
-
-class TVGonkService final : public nsITVService
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSITVSERVICE
-
-  TVGonkService();
-
-private:
-  ~TVGonkService();
-
-  void GetSourceListeners(
-    const nsAString& aTunerId, const nsAString& aSourceType,
-    nsTArray<nsCOMPtr<nsITVSourceListener> >& aListeners) const;
-
-  nsTArray<UniquePtr<TVSourceListenerTuple>> mSourceListenerTuples;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_TVGonkService_h
deleted file mode 100644
--- a/dom/tv/ipc/PTV.ipdl
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-include protocol PContent;
-include protocol PTVRequest;
-include PTVTypes;
-
-namespace mozilla {
-namespace dom {
-
-struct TVGetTunersRequest {
-};
-
-struct TVSetSourceRequest {
-  nsString tunerId;
-  nsString sourceType;
-};
-
-struct TVStartScanningChannelsRequest {
-  nsString tunerId;
-  nsString sourceType;
-};
-
-struct TVStopScanningChannelsRequest {
-  nsString tunerId;
-  nsString sourceType;
-};
-
-struct TVClearScannedChannelsCacheRequest {
-};
-
-struct TVSetChannelRequest {
-  nsString tunerId;
-  nsString sourceType;
-  nsString channelNumber;
-};
-
-struct TVGetChannelsRequest {
-  nsString tunerId;
-  nsString sourceType;
-};
-
-struct TVGetProgramsRequest {
-  nsString tunerId;
-  nsString sourceType;
-  nsString channelNumber;
-  uint64_t startTime;
-  uint64_t endTime;
-};
-
-union TVIPCRequest {
-  TVGetTunersRequest;
-  TVSetSourceRequest;
-  TVStartScanningChannelsRequest;
-  TVStopScanningChannelsRequest;
-  TVClearScannedChannelsCacheRequest;
-  TVSetChannelRequest;
-  TVGetChannelsRequest;
-  TVGetProgramsRequest;
-};
-
-protocol PTV {
-  manager PContent;
-  manages PTVRequest;
-
-child:
-  async NotifyChannelScanned(nsString tunerId, nsString sourceType,
-                             TVIPCChannelData channelData);
-  async NotifyChannelScanComplete(nsString tunerId, nsString sourceType);
-  async NotifyChannelScanStopped(nsString tunerId, nsString sourceType);
-  async NotifyEITBroadcasted(nsString tunerId, nsString sourceType,
-                             TVIPCChannelData channelData,
-                             TVIPCProgramData[] programData);
-
-parent:
-  async __delete__();
-
-  async PTVRequest(TVIPCRequest aRequest);
-
-  async RegisterSourceHandler(nsString tunerId, nsString sourceType);
-  async UnregisterSourceHandler(nsString tunerId, nsString sourceType);
-};
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/tv/ipc/PTVRequest.ipdl
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-include protocol PTV;
-include PTVTypes;
-
-namespace mozilla {
-namespace dom {
-
-
-struct TVSuccessResponse {
-};
-
-struct TVErrorResponse {
-  uint16_t errorCode;
-};
-
-struct TVGetTunersResponse {
-  TVIPCTunerData[] tuners;
-};
-
-struct TVSetSourceResponse {
-  TVIPCGonkNativeHandleData streamHandle;
-};
-
-struct TVSetChannelResponse {
-  TVIPCChannelData channel;
-};
-
-struct TVGetChannelsResponse {
-  TVIPCChannelData[] channels;
-};
-
-struct TVGetProgramsResponse {
-  TVIPCProgramData[] programs;
-};
-
-union TVIPCResponse {
-  TVSuccessResponse;
-  TVErrorResponse;
-  TVGetTunersResponse;
-  TVSetSourceResponse;
-  TVSetChannelResponse;
-  TVGetChannelsResponse;
-  TVGetProgramsResponse;
-};
-
-protocol PTVRequest
-{
-  manager PTV;
-
-child:
-  async __delete__(TVIPCResponse aResponse);
-};
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/tv/ipc/PTVTypes.ipdlh
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-using struct mozilla::layers::GonkNativeHandle from "mozilla/layers/GonkNativeHandleUtils.h";
-using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
-
-namespace mozilla {
-namespace dom {
-
-struct TVIPCTunerData {
-  nsString id;
-  uint16_t streamType;
-  uint32_t sourceTypeCount;
-  nsCString[] sourceTypes;
-};
-
-struct TVIPCChannelData {
-  nsCString networkId;
-  nsCString transportStreamId;
-  nsCString serviceId;
-  nsCString type;
-  nsCString number;
-  nsCString name;
-  bool isEmergency;
-  bool isFree;
-};
-
-struct TVIPCProgramData {
-  nsCString eventId;
-  nsCString title;
-  uint64_t startTime;
-  uint64_t duration;
-  nsCString description;
-  nsCString rating;
-  uint32_t audioLanguageCount;
-  nsCString[] audioLanguages;
-  uint32_t subtitleLanguageCount;
-  nsCString[] subtitleLanguages;
-};
-
-union StreamHandle {
-  GonkNativeHandle;
-  null_t;
-};
-
-struct TVIPCGonkNativeHandleData {
-  StreamHandle handle;
-};
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/tv/ipc/TVChild.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TVChild.h"
-
-#include "mozilla/unused.h"
-#include "nsIMutableArray.h"
-#include "TVIPCHelper.h"
-#include "TVIPCService.h"
-#include "TVServiceRunnables.h"
-#include "TVTuner.h"
-
-using namespace mozilla;
-
-namespace mozilla {
-namespace dom {
-
-/*
- * Implementation of TVChild
- */
-
-TVChild::TVChild(TVIPCService* aService)
-  : mActorDestroyed(false), mService(aService)
-{
-  MOZ_ASSERT(mService);
-
-  MOZ_COUNT_CTOR(TVChild);
-}
-
-TVChild::~TVChild()
-{
-  MOZ_COUNT_DTOR(TVChild);
-
-  if (!mActorDestroyed) {
-    Send__delete__(this);
-  }
-  mService = nullptr;
-}
-
-/* virtual */ void
-TVChild::ActorDestroy(ActorDestroyReason aWhy)
-{
-  mActorDestroyed = true;
-  mService = nullptr;
-}
-
-/* virtual */ PTVRequestChild*
-TVChild::AllocPTVRequestChild(const TVIPCRequest& aRequest)
-{
-  NS_NOTREACHED(
-    "We should never be manually allocating PTVRequestChild actors");
-  return nullptr;
-}
-
-/* virtual */ bool
-TVChild::DeallocPTVRequestChild(PTVRequestChild* aActor)
-{
-  delete aActor;
-  return true;
-}
-
-/* virtual */ bool
-TVChild::RecvNotifyChannelScanned(const nsString& aTunerId,
-                                  const nsString& aSourceType,
-                                  const TVIPCChannelData& aChannelData)
-{
-  if (mService) {
-    nsCOMPtr<nsITVChannelData> channelData;
-    channelData = do_CreateInstance(TV_CHANNEL_DATA_CONTRACTID);
-    UnpackTVIPCChannelData(channelData, aChannelData);
-    NS_WARN_IF(NS_FAILED(
-      mService->NotifyChannelScanned(aTunerId, aSourceType, channelData)));
-  }
-  return true;
-}
-
-/* virtual */ bool
-TVChild::RecvNotifyChannelScanComplete(const nsString& aTunerId,
-                                       const nsString& aSourceType)
-{
-  if (mService) {
-    NS_WARN_IF(
-      NS_FAILED(mService->NotifyChannelScanComplete(aTunerId, aSourceType)));
-  }
-  return true;
-}
-
-/* virtual */ bool
-TVChild::RecvNotifyChannelScanStopped(const nsString& aTunerId,
-                                      const nsString& aSourceType)
-{
-  if (mService) {
-    NS_WARN_IF(
-      NS_FAILED(mService->NotifyChannelScanStopped(aTunerId, aSourceType)));
-  }
-  return true;
-}
-
-/* virtual */ bool
-TVChild::RecvNotifyEITBroadcasted(const nsString& aTunerId,
-                                  const nsString& aSourceType,
-                                  const TVIPCChannelData& aChannelData,
-                                  nsTArray<TVIPCProgramData>&& aProgramDataList)
-{
-  if (mService) {
-    nsCOMPtr<nsITVChannelData> channelData;
-    channelData = do_CreateInstance(TV_CHANNEL_DATA_CONTRACTID);
-    UnpackTVIPCChannelData(channelData, aChannelData);
-
-    uint32_t count = aProgramDataList.Length();
-    nsCOMArray<nsITVProgramData> programDataList(count);
-    for (uint32_t i = 0; i < count; i++) {
-      nsCOMPtr<nsITVProgramData> programData;
-      programData = do_CreateInstance(TV_PROGRAM_DATA_CONTRACTID);
-      UnpackTVIPCProgramData(programData, aProgramDataList[i]);
-      programDataList.AppendElement(programData);
-    }
-
-    nsresult rv = mService->NotifyEITBroadcasted(
-      aTunerId,
-      aSourceType,
-      channelData,
-      const_cast<nsITVProgramData**>(programDataList.Elements()),
-      count);
-
-    NS_WARN_IF(NS_FAILED(rv));
-  }
-  return true;
-}
-
-/*
- * Implementation of TVRequestChild
- */
-
-TVRequestChild::TVRequestChild(nsITVServiceCallback* aCallback)
-  : mActorDestroyed(false), mCallback(aCallback)
-{
-  MOZ_COUNT_CTOR(TVRequestChild);
-}
-
-TVRequestChild::~TVRequestChild()
-{
-  MOZ_COUNT_DTOR(TVRequestChild);
-
-  mCallback = nullptr;
-}
-
-/* virtual */ void
-TVRequestChild::ActorDestroy(ActorDestroyReason aWhy)
-{
-  mActorDestroyed = true;
-  mCallback = nullptr;
-}
-
-/* virtual */ bool
-TVRequestChild::Recv__delete__(const TVIPCResponse& aResponse)
-{
-  if (mActorDestroyed) {
-    return true;
-  }
-
-  if (!mCallback) {
-    return true;
-  }
-
-  switch (aResponse.type()) {
-    case TVIPCResponse::TTVSuccessResponse:
-      DoResponse(aResponse.get_TVSuccessResponse());
-      break;
-    case TVIPCResponse::TTVErrorResponse:
-      DoResponse(aResponse.get_TVErrorResponse());
-      break;
-    case TVIPCResponse::TTVGetTunersResponse:
-      DoResponse(aResponse.get_TVGetTunersResponse());
-      break;
-    case TVIPCResponse::TTVSetSourceResponse:
-      DoResponse(aResponse.get_TVSetSourceResponse());
-      break;
-    case TVIPCResponse::TTVSetChannelResponse:
-      DoResponse(aResponse.get_TVSetChannelResponse());
-      break;
-    case TVIPCResponse::TTVGetChannelsResponse:
-      DoResponse(aResponse.get_TVGetChannelsResponse());
-      break;
-    case TVIPCResponse::TTVGetProgramsResponse:
-      DoResponse(aResponse.get_TVGetProgramsResponse());
-      break;
-    default:
-      MOZ_CRASH("Unknown TVIPCResponse type");
-  }
-
-  return true;
-}
-
-void
-TVRequestChild::DoResponse(const TVSuccessResponse& aResponse)
-{
-  if (mCallback) {
-    Unused << mCallback->NotifySuccess(nullptr);
-  }
-}
-
-void
-TVRequestChild::DoResponse(const TVErrorResponse& aResponse)
-{
-  if (mCallback) {
-    Unused << mCallback->NotifyError(aResponse.errorCode());
-  }
-}
-
-void
-TVRequestChild::DoResponse(const TVGetTunersResponse& aResponse)
-{
-  MOZ_ASSERT(mCallback);
-
-  nsCOMPtr<nsIMutableArray> tunerDataList =
-    do_CreateInstance(NS_ARRAY_CONTRACTID);
-  if (!tunerDataList) {
-    NS_WARNING("OUT OF MEMORY");
-    return;
-  }
-
-  const nsTArray<TVIPCTunerData>& tuners = aResponse.tuners();
-  for (uint32_t i = 0; i < tuners.Length(); i++) {
-    nsCOMPtr<nsITVTunerData> tunerData;
-    tunerData = do_CreateInstance(TV_TUNER_DATA_CONTRACTID);
-    UnpackTVIPCTunerData(tunerData, tuners[i]);
-    tunerDataList->AppendElement(tunerData, false);
-  }
-
-  nsCOMPtr<nsIRunnable> runnable =
-    new TVServiceNotifyRunnable(mCallback, tunerDataList);
-  Unused << NS_DispatchToCurrentThread(runnable);
-}
-
-void
-TVRequestChild::DoResponse(const TVSetSourceResponse& aResponse)
-{
-  MOZ_ASSERT(mCallback);
-
-  nsCOMPtr<nsIMutableArray> handleDataList =
-    do_CreateInstance(NS_ARRAY_CONTRACTID);
-  if (!handleDataList) {
-    NS_WARNING("OUT OF MEMORY");
-    return;
-  }
-
-  nsCOMPtr<nsITVGonkNativeHandleData> handleData;
-  handleData = do_CreateInstance(TV_GONK_NATIVE_HANDLE_DATA_CONTRACTID);
-  UnpackTVIPCGonkNativeHandleData(handleData, aResponse.streamHandle());
-  handleDataList->AppendElement(handleData, false);
-
-  nsCOMPtr<nsIRunnable> runnable =
-    new TVServiceNotifyRunnable(mCallback, handleDataList);
-  Unused << NS_DispatchToCurrentThread(runnable);
-}
-
-void
-TVRequestChild::DoResponse(const TVSetChannelResponse& aResponse)
-{
-  MOZ_ASSERT(mCallback);
-
-  nsCOMPtr<nsIMutableArray> channelDataList =
-    do_CreateInstance(NS_ARRAY_CONTRACTID);
-  if (!channelDataList) {
-    NS_WARNING("OUT OF MEMORY");
-    return;
-  }
-
-  nsCOMPtr<nsITVChannelData> channelData;
-  channelData = do_CreateInstance(TV_CHANNEL_DATA_CONTRACTID);
-  UnpackTVIPCChannelData(channelData, aResponse.channel());
-  channelDataList->AppendElement(channelData, false);
-
-  nsCOMPtr<nsIRunnable> runnable =
-    new TVServiceNotifyRunnable(mCallback, channelDataList);
-  Unused << NS_DispatchToCurrentThread(runnable);
-}
-
-void
-TVRequestChild::DoResponse(const TVGetChannelsResponse& aResponse)
-{
-  MOZ_ASSERT(mCallback);
-
-  nsCOMPtr<nsIMutableArray> channelDataList =
-    do_CreateInstance(NS_ARRAY_CONTRACTID);
-  if (!channelDataList) {
-    NS_WARNING("OUT OF MEMORY");
-    return;
-  }
-
-  const nsTArray<TVIPCChannelData>& channels = aResponse.channels();
-  for (uint32_t i = 0; i < channels.Length(); i++) {
-    nsCOMPtr<nsITVChannelData> channelData;
-    channelData = do_CreateInstance(TV_CHANNEL_DATA_CONTRACTID);
-    UnpackTVIPCChannelData(channelData, channels[i]);
-
-    channelDataList->AppendElement(channelData, false);
-  }
-
-  nsCOMPtr<nsIRunnable> runnable =
-    new TVServiceNotifyRunnable(mCallback, channelDataList);
-  Unused << NS_DispatchToCurrentThread(runnable);
-}
-
-void
-TVRequestChild::DoResponse(const TVGetProgramsResponse& aResponse)
-{
-  MOZ_ASSERT(mCallback);
-
-  nsCOMPtr<nsIMutableArray> programDataList =
-    do_CreateInstance(NS_ARRAY_CONTRACTID);
-  if (!programDataList) {
-    NS_WARNING("OUT OF MEMORY");
-    return;
-  }
-
-  const nsTArray<TVIPCProgramData>& programs = aResponse.programs();
-  for (uint32_t i = 0; i < programs.Length(); i++) {
-    nsCOMPtr<nsITVProgramData> programData;
-    programData = do_CreateInstance(TV_PROGRAM_DATA_CONTRACTID);
-    UnpackTVIPCProgramData(programData, programs[i]);
-    programDataList->AppendElement(programData, false);
-  }
-
-  nsCOMPtr<nsIRunnable> runnable =
-    new TVServiceNotifyRunnable(mCallback, programDataList);
-  Unused << NS_DispatchToCurrentThread(runnable);
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/tv/ipc/TVChild.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_TVChild_h
-#define mozilla_dom_TVChild_h
-
-#include "mozilla/dom/PTVChild.h"
-#include "mozilla/dom/PTVRequestChild.h"
-#include "mozilla/dom/PTVTypes.h"
-
-class nsITVServiceCallback;
-
-namespace mozilla {
-namespace dom {
-
-class TVIPCService;
-
-class TVChild final : public PTVChild
-{
-public:
-  explicit TVChild(TVIPCService* aService);
-
-  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
-  virtual PTVRequestChild*
-  AllocPTVRequestChild(const TVIPCRequest& aRequest) override;
-
-  virtual bool DeallocPTVRequestChild(PTVRequestChild* aActor) override;
-
-  virtual bool
-  RecvNotifyChannelScanned(const nsString& aTunerId,
-                           const nsString& aSourceType,
-                           const TVIPCChannelData& aChannelData) override;
-
-  virtual bool
-  RecvNotifyChannelScanComplete(const nsString& aTunerId,
-                                const nsString& aSourceType) override;
-
-  virtual bool
-  RecvNotifyChannelScanStopped(const nsString& aTunerId,
-                               const nsString& aSourceType) override;
-
-  virtual bool
-  RecvNotifyEITBroadcasted(
-                        const nsString& aTunerId,
-                        const nsString& aSourceType,
-                        const TVIPCChannelData& aChannelData,
-                        nsTArray<TVIPCProgramData>&& aProgramDataList) override;
-
-  virtual ~TVChild();
-
-private:
-  bool mActorDestroyed;
-  RefPtr<TVIPCService> mService;
-};
-
-class TVRequestChild final : public PTVRequestChild
-{
-public:
-  explicit TVRequestChild(nsITVServiceCallback* aCallback);
-
-  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
-  virtual bool Recv__delete__(const TVIPCResponse& aResponse) override;
-
-private:
-  virtual ~TVRequestChild();
-
-  void DoResponse(const TVSuccessResponse& aResponse);
-
-  void DoResponse(const TVErrorResponse& aResponse);
-
-  void DoResponse(const TVGetTunersResponse& aResponse);
-
-  void DoResponse(const TVSetSourceResponse& aResponse);
-
-  void DoResponse(const TVSetChannelResponse& aResponse);
-
-  void DoResponse(const TVGetChannelsResponse& aResponse);
-
-  void DoResponse(const TVGetProgramsResponse& aResponse);
-
-  bool mActorDestroyed;
-  nsCOMPtr<nsITVServiceCallback> mCallback;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_TVChild_h
deleted file mode 100644
--- a/dom/tv/ipc/TVIPCHelper.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TVIPCHelper.h"
-#include "nsITVService.h"
-#include "mozilla/dom/PTVTypes.h"
-
-namespace mozilla {
-namespace dom {
-
-/*
- * TVTunerData Pack/Unpack.
- */
-void
-PackTVIPCTunerData(nsITVTunerData* aTunerData, TVIPCTunerData& aIPCTunerData)
-{
-  if (!aTunerData) {
-    return;
-  }
-
-  aTunerData->GetId(aIPCTunerData.id());
-  aTunerData->GetStreamType(&aIPCTunerData.streamType());
-  aTunerData->GetSupportedSourceTypesByString(aIPCTunerData.sourceTypes());
-  aIPCTunerData.sourceTypeCount() = aIPCTunerData.sourceTypes().Length();
-}
-
-void
-UnpackTVIPCTunerData(nsITVTunerData* aTunerData,
-                     const TVIPCTunerData& aIPCTunerData)
-{
-  if (!aTunerData) {
-    return;
-  }
-
-  aTunerData->SetId(aIPCTunerData.id());
-  aTunerData->SetStreamType(aIPCTunerData.streamType());
-  aTunerData->SetSupportedSourceTypesByString(aIPCTunerData.sourceTypes());
-}
-
-/*
- * TVChannelData Pack/Unpack.
- */
-void
-PackTVIPCChannelData(nsITVChannelData* aChannelData,
-                     TVIPCChannelData& aIPCChannelData)
-{
-  if (!aChannelData) {
-    return;
-  }
-
-  nsString networkId;
-  aChannelData->GetNetworkId(networkId);
-  aIPCChannelData.networkId() = NS_ConvertUTF16toUTF8(networkId);
-
-  nsString transportStreamId;
-  aChannelData->GetTransportStreamId(transportStreamId);
-  aIPCChannelData.transportStreamId() =
-    NS_ConvertUTF16toUTF8(transportStreamId);
-
-  nsString serviceId;
-  aChannelData->GetServiceId(serviceId);
-  aIPCChannelData.serviceId() = NS_ConvertUTF16toUTF8(serviceId);
-
-  nsString type;
-  aChannelData->GetType(type);
-  aIPCChannelData.type() = NS_ConvertUTF16toUTF8(type);
-
-  nsString number;
-  aChannelData->GetNumber(number);
-  aIPCChannelData.number() = NS_ConvertUTF16toUTF8(number);
-
-  nsString name;
-  aChannelData->GetName(name);
-  aIPCChannelData.name() = NS_ConvertUTF16toUTF8(name);
-
-  aChannelData->GetIsEmergency(&aIPCChannelData.isEmergency());
-  aChannelData->GetIsFree(&aIPCChannelData.isFree());
-}
-
-void
-UnpackTVIPCChannelData(nsITVChannelData* aChannelData,
-                       const TVIPCChannelData& aIPCChannelData)
-{
-  if (!aChannelData) {
-    return;
-  }
-
-  aChannelData->SetNetworkId(
-    NS_ConvertUTF8toUTF16(aIPCChannelData.networkId()));
-  aChannelData->SetTransportStreamId(
-    NS_ConvertUTF8toUTF16(aIPCChannelData.transportStreamId()));
-  aChannelData->SetServiceId(
-    NS_ConvertUTF8toUTF16(aIPCChannelData.serviceId()));
-  aChannelData->SetType(NS_ConvertUTF8toUTF16(aIPCChannelData.type()));
-  aChannelData->SetNumber(NS_ConvertUTF8toUTF16(aIPCChannelData.number()));
-  aChannelData->SetName(NS_ConvertUTF8toUTF16(aIPCChannelData.name()));
-  aChannelData->SetIsEmergency(aIPCChannelData.isEmergency());
-  aChannelData->SetIsFree(aIPCChannelData.isFree());
-}
-
-/*
- * TVProgramData Pack/Unpack.
- */
-void
-PackTVIPCProgramData(nsITVProgramData* aProgramData,
-                     TVIPCProgramData& aIPCProgramData)
-{
-  if (!aProgramData) {
-    return;
-  }
-
-  nsString eventId;
-  aProgramData->GetEventId(eventId);
-  aIPCProgramData.eventId() = NS_ConvertUTF16toUTF8(eventId);
-
-  nsString title;
-  aProgramData->GetTitle(title);
-  aIPCProgramData.title() = NS_ConvertUTF16toUTF8(title);
-
-  aProgramData->GetStartTime(&aIPCProgramData.startTime());
-
-  aProgramData->GetDuration(&aIPCProgramData.duration());
-
-  nsString description;
-  aProgramData->GetDescription(description);
-  aIPCProgramData.description() = NS_ConvertUTF16toUTF8(description);
-
-  nsString rating;
-  aProgramData->GetRating(rating);
-  aIPCProgramData.rating() = NS_ConvertUTF16toUTF8(rating);
-
-  aProgramData->GetAudioLanguagesByString(aIPCProgramData.audioLanguages());
-  aIPCProgramData.audioLanguageCount() =
-    aIPCProgramData.audioLanguages().Length();
-
-  aProgramData->GetSubtitleLanguagesByString(
-    aIPCProgramData.subtitleLanguages());
-  aIPCProgramData.subtitleLanguageCount() =
-    aIPCProgramData.subtitleLanguages().Length();
-}
-
-void
-UnpackTVIPCProgramData(nsITVProgramData* aProgramData,
-                       const TVIPCProgramData& aIPCProgramData)
-{
-  if (!aProgramData) {
-    return;
-  }
-
-  aProgramData->SetEventId(NS_ConvertUTF8toUTF16(aIPCProgramData.eventId()));
-  aProgramData->SetTitle(NS_ConvertUTF8toUTF16(aIPCProgramData.title()));
-  aProgramData->SetStartTime(aIPCProgramData.startTime());
-  aProgramData->SetDuration(aIPCProgramData.duration());
-  aProgramData->SetDescription(
-    NS_ConvertUTF8toUTF16(aIPCProgramData.description()));
-  aProgramData->SetRating(NS_ConvertUTF8toUTF16(aIPCProgramData.rating()));
-  aProgramData->SetAudioLanguagesByString(aIPCProgramData.audioLanguages());
-  aProgramData->SetSubtitleLanguagesByString(
-    aIPCProgramData.subtitleLanguages());
-}
-
-/**
- * nsITVGonkNativeHandleData Serialize/De-serialize.
- */
-void
-PackTVIPCGonkNativeHandleData(nsITVGonkNativeHandleData* aNativeHandleData,
-                              TVIPCGonkNativeHandleData& aIPCNativeHandleData)
-{
-#ifdef MOZ_WIDGET_GONK
-  if (!aNativeHandleData) {
-    return;
-  }
-
-  aNativeHandleData->GetHandle(aIPCNativeHandleData.handle());
-#else
-  aIPCNativeHandleData.handle() = null_t();
-#endif
-}
-
-void
-UnpackTVIPCGonkNativeHandleData(
-  nsITVGonkNativeHandleData* aNativeHandleData,
-  const TVIPCGonkNativeHandleData& aIPCNativeHandleData)
-{
-#ifdef MOZ_WIDGET_GONK
-  if (!aNativeHandleData) {
-    return;
-  }
-
-   aNativeHandleData->SetHandle(
-     const_cast<StreamHandle&>(aIPCNativeHandleData.handle()));
-#endif
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/tv/ipc/TVIPCHelper.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_TVIPCHelper_h
-#define mozilla_dom_TVIPCHelper_h
-
-#include "mozilla/dom/PTVTypes.h"
-#include "nsITVService.h"
-
-namespace mozilla {
-namespace dom {
-
-/*
- * TVTunerData Pack/Unpack.
- */
-void
-PackTVIPCTunerData(nsITVTunerData* aTunerData, TVIPCTunerData& aIPCTunerData);
-
-void
-UnpackTVIPCTunerData(nsITVTunerData* aTunerData,
-                     const TVIPCTunerData& aIPCTunerData);
-
-/*
- * TVChannelData Pack/Unpack.
- */
-void
-PackTVIPCChannelData(nsITVChannelData* aChannelData,
-                     TVIPCChannelData& aIPCChannelData);
-
-void
-UnpackTVIPCChannelData(nsITVChannelData* aChannelData,
-                       const TVIPCChannelData& aIPCChannelData);
-
-/*
- * TVProgramData Pack/Unpack.
- */
-void
-PackTVIPCProgramData(nsITVProgramData* aProgramData,
-                     TVIPCProgramData& aIPCProgramData);
-
-void
-UnpackTVIPCProgramData(nsITVProgramData* aProgramData,
-                       const TVIPCProgramData& aIPCProgramData);
-
-/**
- * nsITVGonkNativeHandleData Serialize/De-serialize.
- */
-void
-PackTVIPCGonkNativeHandleData(nsITVGonkNativeHandleData* aNativeHandleData,
-                              TVIPCGonkNativeHandleData& aIPCNativeHandleData);
-
-void
-UnpackTVIPCGonkNativeHandleData(
-  nsITVGonkNativeHandleData* aNativeHandleData,
-  const TVIPCGonkNativeHandleData& aIPCNativeHandleData);
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_TVIPCHelper_h
deleted file mode 100644
--- a/dom/tv/ipc/TVIPCService.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TVIPCService.h"
-
-#include "mozilla/dom/ContentChild.h"
-#include "TVChild.h"
-
-namespace mozilla {
-namespace dom {
-
-static StaticAutoPtr<TVChild> sTVChild;
-
-NS_IMPL_ISUPPORTS(TVIPCService, nsITVService)
-
-TVIPCService::TVIPCService()
-{
-  ContentChild* contentChild = ContentChild::GetSingleton();
-  if (NS_WARN_IF(!contentChild)) {
-    return;
-  }
-  sTVChild = new TVChild(this);
-  NS_WARN_IF(!contentChild->SendPTVConstructor(sTVChild));
-}
-
-/* virtual */
-TVIPCService::~TVIPCService()
-{
-  sTVChild = nullptr;
-}
-
-NS_IMETHODIMP
-TVIPCService::RegisterSourceListener(const nsAString& aTunerId,
-                                     const nsAString& aSourceType,
-                                     nsITVSourceListener* aListener)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(aListener);
-
-  mSourceListenerTuples.AppendElement(new TVSourceListenerTuple(
-    nsString(aTunerId), nsString(aSourceType), aListener));
-
-  if (sTVChild) {
-    NS_WARN_IF(!sTVChild->SendRegisterSourceHandler(nsAutoString(aTunerId),
-                                                    nsAutoString(aSourceType)));
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-TVIPCService::UnregisterSourceListener(const nsAString& aTunerId,
-                                       const nsAString& aSourceType,
-                                       nsITVSourceListener* aListener)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!aTunerId.IsEmpty());
-  MOZ_ASSERT(!aSourceType.IsEmpty());
-  MOZ_ASSERT(aListener);
-
-  for (uint32_t i = 0; i < mSourceListenerTuples.Length(); i++) {
-    const UniquePtr<TVSourceListenerTuple>& tuple = mSourceListenerTuples[i];
-    if (aTunerId.Equals(Get<0>(*tuple)) && aSourceType.Equals(Get<1>(*tuple)) &&
-        aListener == Get<2>(*tuple)) {
-      mSourceListenerTuples.RemoveElementAt(i);
-      break;
-    }
-  }
-
-  if (sTVChild) {
-    NS_WARN_IF(!sTVChild->SendUnregisterSourceHandler(
-                  nsAutoString(aTunerId), nsAutoString(aSourceType)));
-  }
-
-  return NS_OK;
-}
-
-void
-TVIPCService::GetSourceListeners(
-  const nsAString& aTunerId,
-  const nsAString& aSourceType,
-  nsTArray<nsCOMPtr<nsITVSourceListener>>& aListeners) const
-{
-  aListeners.Clear();
-
-  for (uint32_t i = 0; i < mSourceListenerTuples.Length(); i++) {
-    const UniquePtr<TVSourceListenerTuple>& tuple = mSourceListenerTuples[i];
-    nsCOMPtr<nsITVSourceListener> listener = Get<2>(*tuple);
-    if (aTunerId.Equals(Get<0>(*tuple)) && aSourceType.Equals(Get<1>(*tuple))) {
-      aListeners.AppendElement(listener);
-      break;
-    }
-  }
-}
-
-/* virtual */ NS_IMETHODIMP
-TVIPCService::GetTuners(nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!aCallback) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return SendRequest(aCallback, TVGetTunersRequest());
-}
-
-/* virtual */ NS_IMETHODIMP
-TVIPCService::SetSource(const nsAString& aTunerId,
-                        const nsAString& aSourceType,
-                        nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!aCallback) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return SendRequest(aCallback, TVSetSourceRequest(nsAutoString(aTunerId),
-                                                   nsAutoString(aSourceType)));
-}
-
-/* virtual */ NS_IMETHODIMP
-TVIPCService::StartScanningChannels(const nsAString& aTunerId,
-                                    const nsAString& aSourceType,
-                                    nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!aCallback) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return SendRequest(aCallback,
-                     TVStartScanningChannelsRequest(nsAutoString(aTunerId),
-                                                    nsAutoString(aSourceType)));
-}
-
-/* virtual */ NS_IMETHODIMP
-TVIPCService::StopScanningChannels(const nsAString& aTunerId,
-                                   const nsAString& aSourceType,
-                                   nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!aCallback) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return SendRequest(aCallback,
-                     TVStopScanningChannelsRequest(nsAutoString(aTunerId),
-                                                   nsAutoString(aSourceType)));
-}
-
-/* virtual */ NS_IMETHODIMP
-TVIPCService::ClearScannedChannelsCache()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  return SendRequest(nullptr, TVClearScannedChannelsCacheRequest());
-}
-
-/* virtual */ NS_IMETHODIMP
-TVIPCService::SetChannel(const nsAString& aTunerId,
-                         const nsAString& aSourceType,
-                         const nsAString& aChannelNumber,
-                         nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!aCallback) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return SendRequest(aCallback,
-                     TVSetChannelRequest(nsAutoString(aTunerId),
-                                         nsAutoString(aSourceType),
-                                         nsAutoString(aChannelNumber)));
-}
-
-/* virtual */ NS_IMETHODIMP
-TVIPCService::GetChannels(const nsAString& aTunerId,
-                          const nsAString& aSourceType,
-                          nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!aCallback) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return SendRequest(aCallback,
-                     TVGetChannelsRequest(nsAutoString(aTunerId),
-                                          nsAutoString(aSourceType)));
-}
-
-/* virtual */ NS_IMETHODIMP
-TVIPCService::GetPrograms(const nsAString& aTunerId,
-                          const nsAString& aSourceType,
-                          const nsAString& aChannelNumber, uint64_t startTime,
-                          uint64_t endTime, nsITVServiceCallback* aCallback)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!aCallback) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return SendRequest(aCallback,
-                     TVGetProgramsRequest(nsAutoString(aTunerId),
-                                          nsAutoString(aSourceType),
-                                          nsAutoString(aChannelNumber),
-                                          startTime, endTime));
-}
-
-nsresult
-TVIPCService::SendRequest(nsITVServiceCallback* aCallback,
-                          const TVIPCRequest& aRequest)
-{
-  if (sTVChild) {
-    TVRequestChild* actor = new TVRequestChild(aCallback);
-    NS_WARN_IF(!sTVChild->SendPTVRequestConstructor(actor, aRequest));
-  }
-  return NS_OK;
-}
-
-nsresult
-TVIPCService::NotifyChannelScanned(const nsAString& aTunerId,
-                                   const nsAString& aSourceType,
-                                   nsITVChannelData* aChannelData)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsTArray<nsCOMPtr<nsITVSourceListener>> listeners;
-  GetSourceListeners(aTunerId, aSourceType, listeners);
-  for (uint32_t i = 0; i < listeners.Length(); i++) {
-    nsresult rv =
-      listeners[i]->NotifyChannelScanned(aTunerId, aSourceType, aChannelData);
-    NS_WARN_IF(NS_FAILED(rv));
-  }
-
-  return NS_OK;
-}
-
-nsresult
-TVIPCService::NotifyChannelScanComplete(const nsAString& aTunerId,
-                                        const nsAString& aSourceType)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsTArray<nsCOMPtr<nsITVSourceListener>> listeners;
-  GetSourceListeners(aTunerId, aSourceType, listeners);
-  for (uint32_t i = 0; i < listeners.Length(); i++) {
-    nsresult rv =
-      listeners[i]->NotifyChannelScanComplete(aTunerId, aSourceType);
-    NS_WARN_IF(NS_FAILED(rv));
-  }
-
-  return NS_OK;
-}
-
-nsresult
-TVIPCService::NotifyChannelScanStopped(const nsAString& aTunerId,
-                                       const nsAString& aSourceType)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsTArray<nsCOMPtr<nsITVSourceListener>> listeners;
-  GetSourceListeners(aTunerId, aSourceType, listeners);
-  for (uint32_t i = 0; i < listeners.Length(); i++) {
-    nsresult rv = listeners[i]->NotifyChannelScanStopped(aTunerId, aSourceType);
-    NS_WARN_IF(NS_FAILED(rv));
-  }
-
-  return NS_OK;
-}
-
-nsresult
-TVIPCService::NotifyEITBroadcasted(const nsAString& aTunerId,
-                                   const nsAString& aSourceType,
-                                   nsITVChannelData* aChannelData,
-                                   nsITVProgramData** aProgramDataList,
-                                   uint32_t aCount)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsTArray<nsCOMPtr<nsITVSourceListener>> listeners;
-  GetSourceListeners(aTunerId, aSourceType, listeners);
-  for (uint32_t i = 0; i < listeners.Length(); i++) {
-    nsresult rv = listeners[i]->NotifyEITBroadcasted(
-      aTunerId, aSourceType, aChannelData, aProgramDataList, aCount);
-    NS_WARN_IF(NS_FAILED(rv));
-  }
-
-  return NS_OK;
-}
-
-} // dom
-} // mozilla
deleted file mode 100644
--- a/dom/tv/ipc/TVIPCService.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_TVIPCService_h
-#define mozilla_dom_TVIPCService_h
-
-#include "mozilla/Tuple.h"
-#include "nsITVService.h"
-#include "nsTArray.h"
-#include "TVTypes.h"
-
-namespace mozilla {
-namespace dom {
-
-class TVIPCRequest;
-
-class TVIPCService final : public nsITVService
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSITVSERVICE
-
-  TVIPCService();
-
-  nsresult NotifyChannelScanned(const nsAString& aTunerId,
-                                const nsAString& aSourceType,
-                                nsITVChannelData* aChannelData);
-
-  nsresult NotifyChannelScanComplete(const nsAString& aTunerId,
-                                     const nsAString& aSourceType);
-
-  nsresult NotifyChannelScanStopped(const nsAString& aTunerId,
-                                    const nsAString& aSourceType);
-
-  nsresult NotifyEITBroadcasted(const nsAString& aTunerId,
-                                const nsAString& aSourceType,
-                                nsITVChannelData* aChannelData,
-                                nsITVProgramData** aProgramDataList,
-                                uint32_t aCount);
-
-private:
-  virtual ~TVIPCService();
-
-  void GetSourceListeners(
-    const nsAString& aTunerId, const nsAString& aSourceType,
-    nsTArray<nsCOMPtr<nsITVSourceListener>>& aListeners) const;
-
-  nsresult SendRequest(nsITVServiceCallback* aCallback,
-                       const TVIPCRequest& aRequest);
-
-  nsTArray<UniquePtr<TVSourceListenerTuple>> mSourceListenerTuples;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_TVIPCService_h
deleted file mode 100644
--- a/dom/tv/ipc/TVParent.cpp
+++ /dev/null
@@ -1,652 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TVParent.h"
-
-#include "mozilla/unused.h"
-#include "TVTypes.h"
-#include "TVIPCHelper.h"
-
-namespace mozilla {
-namespace dom {
-
-/*
- * Implementation of TVParent
- */
-
-NS_IMPL_ISUPPORTS(TVParent, nsITVSourceListener)
-
-TVParent::TVParent() {}
-
-TVParent::~TVParent() {}
-
-bool
-TVParent::Init()
-{
-  MOZ_ASSERT(!mService);
-  mService = do_GetService(TV_SERVICE_CONTRACTID);
-  return NS_WARN_IF(!mService) ? false : true;
-}
-
-/* virtual */ void
-TVParent::ActorDestroy(ActorDestroyReason aWhy)
-{
-  mService = nullptr;
-}
-
-/* virtual */ bool
-TVParent::RecvPTVRequestConstructor(PTVRequestParent* aActor,
-                                    const TVIPCRequest& aRequest)
-{
-  TVRequestParent* actor = static_cast<TVRequestParent*>(aActor);
-
-  switch (aRequest.type()) {
-    case TVIPCRequest::TTVGetTunersRequest:
-      actor->DoRequest(aRequest.get_TVGetTunersRequest());
-      break;
-    case TVIPCRequest::TTVSetSourceRequest:
-      actor->DoRequest(aRequest.get_TVSetSourceRequest());
-      break;
-    case TVIPCRequest::TTVStartScanningChannelsRequest:
-      actor->DoRequest(aRequest.get_TVStartScanningChannelsRequest());
-      break;
-    case TVIPCRequest::TTVStopScanningChannelsRequest:
-      actor->DoRequest(aRequest.get_TVStopScanningChannelsRequest());
-      break;
-    case TVIPCRequest::TTVClearScannedChannelsCacheRequest:
-      actor->DoRequest(aRequest.get_TVClearScannedChannelsCacheRequest());
-      break;
-    case TVIPCRequest::TTVSetChannelRequest:
-      actor->DoRequest(aRequest.get_TVSetChannelRequest());
-      break;
-    case TVIPCRequest::TTVGetChannelsRequest:
-      actor->DoRequest(aRequest.get_TVGetChannelsRequest());
-      break;
-    case TVIPCRequest::TTVGetProgramsRequest:
-      actor->DoRequest(aRequest.get_TVGetProgramsRequest());
-      break;
-    default:
-      MOZ_CRASH("Unknown TVIPCRequest type");
-  }
-
-  return true;
-}
-
-/* virtual */ PTVRequestParent*
-TVParent::AllocPTVRequestParent(const TVIPCRequest& aRequest)
-{
-  MOZ_ASSERT(mService);
-  RefPtr<TVRequestParent> actor = new TVRequestParent(mService);
-  return actor.forget().take();
-}
-
-/* virtual */ bool
-TVParent::DeallocPTVRequestParent(PTVRequestParent* aActor)
-{
-  RefPtr<TVRequestParent> actor =
-    dont_AddRef(static_cast<TVRequestParent*>(aActor));
-  return true;
-}
-
-/* virtual */ bool
-TVParent::RecvRegisterSourceHandler(const nsString& aTunerId,
-                                    const nsString& aSourceType)
-{
-  MOZ_ASSERT(mService);
-  NS_WARN_IF(
-    NS_FAILED(mService->RegisterSourceListener(aTunerId, aSourceType, this)));
-  return true;
-}
-
-/* virtual */ bool
-TVParent::RecvUnregisterSourceHandler(const nsString& aTunerId,
-                                      const nsString& aSourceType)
-{
-  MOZ_ASSERT(mService);
-  NS_WARN_IF(
-    NS_FAILED(mService->UnregisterSourceListener(aTunerId, aSourceType, this)));
-  return true;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVParent::NotifyChannelScanned(const nsAString& aTunerId,
-                               const nsAString& aSourceType,
-                               nsITVChannelData* aChannelData)
-{
-  TVIPCChannelData channelData;
-  PackTVIPCChannelData(aChannelData, channelData);
-  if (NS_WARN_IF(!SendNotifyChannelScanned(nsAutoString(aTunerId),
-                                           nsAutoString(aSourceType),
-                                           channelData))) {
-    return NS_ERROR_FAILURE;
-  }
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVParent::NotifyChannelScanComplete(const nsAString& aTunerId,
-                                    const nsAString& aSourceType)
-{
-  if (NS_WARN_IF(!SendNotifyChannelScanComplete(nsAutoString(aTunerId),
-                                                nsAutoString(aSourceType)))) {
-    return NS_ERROR_FAILURE;
-  }
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVParent::NotifyChannelScanStopped(const nsAString& aTunerId,
-                                   const nsAString& aSourceType)
-{
-  if (NS_WARN_IF(!SendNotifyChannelScanStopped(nsAutoString(aTunerId),
-                                               nsAutoString(aSourceType)))) {
-    return NS_ERROR_FAILURE;
-  }
-  return NS_OK;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVParent::NotifyEITBroadcasted(const nsAString& aTunerId,
-                               const nsAString& aSourceType,
-                               nsITVChannelData* aChannelData,
-                               nsITVProgramData** aProgramDataList,
-                               uint32_t aCount)
-{
-  TVIPCChannelData ipcChannelData;
-  nsTArray<TVIPCProgramData> programDataList;
-
-  PackTVIPCChannelData(aChannelData, ipcChannelData);
-  for (uint32_t idx = 0; idx < aCount; idx++) {
-    TVIPCProgramData ipcProgramData;
-    PackTVIPCProgramData(aProgramDataList[idx], ipcProgramData);
-    programDataList.AppendElement(ipcProgramData);
-  }
-
-  if (NS_WARN_IF(!SendNotifyEITBroadcasted(nsAutoString(aTunerId),
-                                           nsAutoString(aSourceType),
-                                           ipcChannelData, programDataList))) {
-    return NS_ERROR_FAILURE;
-  }
-  return NS_OK;
-}
-
-/*
- * Implementation of TVRequestBaseCallback
- */
-
-class TVRequestBaseCallback : public nsITVServiceCallback
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSITVSERVICECALLBACK
-
-  explicit TVRequestBaseCallback(TVRequestParent* aRequestParent)
-    : mRequestParent(aRequestParent)
-  {
-    MOZ_ASSERT(aRequestParent);
-  }
-
-protected:
-  virtual ~TVRequestBaseCallback() {}
-
-  RefPtr<TVRequestParent> mRequestParent;
-};
-
-NS_IMPL_ISUPPORTS(TVRequestBaseCallback, nsITVServiceCallback)
-
-/* virtual */ NS_IMETHODIMP
-TVRequestBaseCallback::NotifySuccess(nsIArray* aDataList)
-{
-  if (NS_WARN_IF(aDataList)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  MOZ_ASSERT(mRequestParent);
-
-  nsresult rv;
-  rv = mRequestParent->SendResponse(TVSuccessResponse());
-  mRequestParent = nullptr;
-
-  return rv;
-}
-
-/* virtual */ NS_IMETHODIMP
-TVRequestBaseCallback::NotifyError(uint16_t aErrorCode)
-{
-  MOZ_ASSERT(mRequestParent);
-
-  nsresult rv;
-  rv = mRequestParent->SendResponse(TVErrorResponse(aErrorCode));
-  mRequestParent = nullptr;
-
-  return rv;
-}
-
-/*
- * Implementation of TVRequestTunerGetterCallback
- */
-
-class TVRequestTunerGetterCallback final : public TVRequestBaseCallback
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-
-  explicit TVRequestTunerGetterCallback(TVRequestParent* aRequestParent)
-    : TVRequestBaseCallback(aRequestParent)
-  {
-  }
-
-  NS_IMETHOD NotifySuccess(nsIArray* aDataList) override;
-
-private:
-  virtual ~TVRequestTunerGetterCallback() {}
-};
-
-NS_IMPL_ISUPPORTS_INHERITED0(TVRequestTunerGetterCallback,
-                             TVRequestBaseCallback)
-
-/* virtual */ NS_IMETHODIMP
-TVRequestTunerGetterCallback::NotifySuccess(nsIArray* aDataList)
-{
-  if (NS_WARN_IF(!aDataList)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  uint32_t length;
-  nsresult rv = aDataList->GetLength(&length);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  nsTArray<TVIPCTunerData> tuners(length);
-  for (uint32_t i = 0; i < length; i++) {
-    nsCOMPtr<nsITVTunerData> tunerData = do_QueryElementAt(aDataList, i);
-    if (NS_WARN_IF(!tunerData)) {
-      return NS_ERROR_INVALID_ARG;
-    }
-    TVIPCTunerData ipcTunerData;
-    PackTVIPCTunerData(tunerData, ipcTunerData);
-
-    tuners.AppendElement(ipcTunerData);
-  }
-
-  MOZ_ASSERT(mRequestParent);
-
-  rv = mRequestParent->SendResponse(TVGetTunersResponse(tuners));
-  mRequestParent = nullptr;
-
-  return rv;
-}
-
-/*
- * Implementation of TVRequestSourceSetterCallback
- */
-
-class TVRequestSourceSetterCallback final : public TVRequestBaseCallback
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-
-  explicit TVRequestSourceSetterCallback(TVRequestParent* aRequestParent)
-    : TVRequestBaseCallback(aRequestParent)
-  {
-  }
-
-  NS_IMETHOD NotifySuccess(nsIArray* aDataList) override;
-
-private:
-  virtual ~TVRequestSourceSetterCallback() {}
-};
-
-NS_IMPL_ISUPPORTS_INHERITED0(TVRequestSourceSetterCallback,
-                             TVRequestBaseCallback)
-
-/* virtual */ NS_IMETHODIMP
-TVRequestSourceSetterCallback::NotifySuccess(nsIArray* aDataList)
-{
-  if (NS_WARN_IF(!aDataList)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  uint32_t length;
-  nsresult rv = aDataList->GetLength(&length);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  if (NS_WARN_IF(length != 1)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  nsCOMPtr<nsITVGonkNativeHandleData> handleData =
-    do_QueryElementAt(aDataList, 0);
-  if (NS_WARN_IF(!handleData)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-  TVIPCGonkNativeHandleData ipcHandleData;
-  PackTVIPCGonkNativeHandleData(handleData, ipcHandleData);
-
-  MOZ_ASSERT(mRequestParent);
-
-  rv = mRequestParent->SendResponse(TVSetSourceResponse(ipcHandleData));
-  mRequestParent = nullptr;
-
-  return rv;
-}
-
-/*
- * Implementation of TVRequestChannelSetterCallback
- */
-
-class TVRequestChannelSetterCallback final : public TVRequestBaseCallback
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-
-  explicit TVRequestChannelSetterCallback(TVRequestParent* aRequestParent)
-    : TVRequestBaseCallback(aRequestParent)
-  {
-  }
-
-  NS_IMETHOD NotifySuccess(nsIArray* aDataList) override;
-
-private:
-  virtual ~TVRequestChannelSetterCallback() {}
-};
-
-NS_IMPL_ISUPPORTS_INHERITED0(TVRequestChannelSetterCallback,
-                             TVRequestBaseCallback)
-
-/* virtual */ NS_IMETHODIMP
-TVRequestChannelSetterCallback::NotifySuccess(nsIArray* aDataList)
-{
-  if (NS_WARN_IF(!aDataList)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  uint32_t length;
-  nsresult rv = aDataList->GetLength(&length);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  if (NS_WARN_IF(length != 1)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  nsCOMPtr<nsITVChannelData> channelData = do_QueryElementAt(aDataList, 0);
-  if (NS_WARN_IF(!channelData)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  TVIPCChannelData ipcChannelData;
-  PackTVIPCChannelData(channelData, ipcChannelData);
-
-  MOZ_ASSERT(mRequestParent);
-
-  rv = mRequestParent->SendResponse(TVSetChannelResponse(ipcChannelData));
-  mRequestParent = nullptr;
-
-  return rv;
-}
-
-/*
- * Implementation of TVRequestChannelGetterCallback
- */
-
-class TVRequestChannelGetterCallback final : public TVRequestBaseCallback
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-
-  explicit TVRequestChannelGetterCallback(TVRequestParent* aRequestParent)
-    : TVRequestBaseCallback(aRequestParent)
-  {
-  }
-
-  NS_IMETHOD NotifySuccess(nsIArray* aDataList) override;
-
-private:
-  virtual ~TVRequestChannelGetterCallback() {}
-};
-
-NS_IMPL_ISUPPORTS_INHERITED0(TVRequestChannelGetterCallback,
-                             TVRequestBaseCallback)
-
-/* virtual */ NS_IMETHODIMP
-TVRequestChannelGetterCallback::NotifySuccess(nsIArray* aDataList)
-{
-  if (NS_WARN_IF(!aDataList)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  uint32_t length;
-  nsresult rv = aDataList->GetLength(&length);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  nsTArray<TVIPCChannelData> channels(length);
-  for (uint32_t i = 0; i < length; i++) {
-    nsCOMPtr<nsITVChannelData> channelData = do_QueryElementAt(aDataList, i);
-    TVIPCChannelData ipcChannelData;
-
-    if (NS_WARN_IF(!channelData)) {
-      return NS_ERROR_INVALID_ARG;
-    }
-
-    PackTVIPCChannelData(channelData, ipcChannelData);
-    channels.AppendElement(ipcChannelData);
-  }
-
-  MOZ_ASSERT(mRequestParent);
-
-  rv = mRequestParent->SendResponse(TVGetChannelsResponse(channels));
-  mRequestParent = nullptr;
-
-  return rv;
-}
-
-/*
- * Implementation of TVRequestProgramGetterCallback
- */
-
-class TVRequestProgramGetterCallback final : public TVRequestBaseCallback
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-
-  explicit TVRequestProgramGetterCallback(TVRequestParent* aRequestParent)
-    : TVRequestBaseCallback(aRequestParent)
-  {
-  }
-
-  NS_IMETHOD NotifySuccess(nsIArray* aDataList) override;
-
-private:
-  virtual ~TVRequestProgramGetterCallback() {}
-};
-
-NS_IMPL_ISUPPORTS_INHERITED0(TVRequestProgramGetterCallback,
-                             TVRequestBaseCallback)
-
-/* virtual */ NS_IMETHODIMP
-TVRequestProgramGetterCallback::NotifySuccess(nsIArray* aDataList)
-{
-  if (NS_WARN_IF(!aDataList)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  uint32_t length;
-  nsresult rv = aDataList->GetLength(&length);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  nsTArray<TVIPCProgramData> programs(length);
-  for (uint32_t i = 0; i < length; i++) {
-    nsCOMPtr<nsITVProgramData> programData = do_QueryElementAt(aDataList, i);
-    if (NS_WARN_IF(!programData)) {
-      return NS_ERROR_INVALID_ARG;
-    }
-    TVIPCProgramData ipcProgramData;
-    PackTVIPCProgramData(programData, ipcProgramData);
-    programs.AppendElement(ipcProgramData);
-  }
-
-  MOZ_ASSERT(mRequestParent);
-
-  rv = mRequestParent->SendResponse(TVGetProgramsResponse(programs));
-  mRequestParent = nullptr;
-
-  return rv;
-}
-
-/*
- * Implementation of TVRequestParent
- */
-
-NS_IMPL_ISUPPORTS0(TVRequestParent)
-
-TVRequestParent::TVRequestParent(nsITVService* aService) : mService(aService)
-{
-  MOZ_COUNT_CTOR(TVRequestParent);
-}
-
-TVRequestParent::~TVRequestParent()
-{
-  MOZ_COUNT_DTOR(TVRequestParent);
-
-  mService = nullptr;
-}
-
-/* virtual */ void
-TVRequestParent::ActorDestroy(ActorDestroyReason aWhy)
-{
-  mService = nullptr;
-}
-
-void
-TVRequestParent::DoRequest(const TVGetTunersRequest& aRequest)
-{
-  MOZ_ASSERT(mService);
-  nsresult rv = mService->GetTuners(new TVRequestTunerGetterCallback(this));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    Unused << SendResponse(
-      TVErrorResponse(nsITVServiceCallback::TV_ERROR_FAILURE));
-  }
-}
-
-void
-TVRequestParent::DoRequest(const TVSetSourceRequest& aRequest)
-{
-  MOZ_ASSERT(mService);
-
-  nsresult rv = mService->SetSource(aRequest.tunerId(), aRequest.sourceType(),
-                                    new TVRequestSourceSetterCallback(this));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    Unused << SendResponse(
-      TVErrorResponse(nsITVServiceCallback::TV_ERROR_FAILURE));
-  }
-}
-
-void
-TVRequestParent::DoRequest(const TVStartScanningChannelsRequest& aRequest)
-{
-  MOZ_ASSERT(mService);
-
-  nsresult rv = mService->StartScanningChannels(
-    aRequest.tunerId(), aRequest.sourceType(), new TVRequestBaseCallback(this));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    Unused << SendResponse(
-      TVErrorResponse(nsITVServiceCallback::TV_ERROR_FAILURE));
-  }
-
-}
-
-void
-TVRequestParent::DoRequest(const TVStopScanningChannelsRequest& aRequest)
-{
-  MOZ_ASSERT(mService);
-
-  nsresult rv = mService->StopScanningChannels(
-    aRequest.tunerId(), aRequest.sourceType(), new TVRequestBaseCallback(this));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    Unused << SendResponse(
-      TVErrorResponse(nsITVServiceCallback::TV_ERROR_FAILURE));
-  }
-}
-
-void
-TVRequestParent::DoRequest(const TVClearScannedChannelsCacheRequest& aRequest)
-{
-  MOZ_ASSERT(mService);
-
-  nsresult rv = mService->ClearScannedChannelsCache();
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    Unused << SendResponse(
-      TVErrorResponse(nsITVServiceCallback::TV_ERROR_FAILURE));
-  }
-  Unused << SendResponse(TVSuccessResponse());
-}
-
-void
-TVRequestParent::DoRequest(const TVSetChannelRequest& aRequest)
-{
-  MOZ_ASSERT(mService);
-
-  nsresult rv = mService->SetChannel(aRequest.tunerId(), aRequest.sourceType(),
-                                     aRequest.channelNumber(),
-                                     new TVRequestChannelSetterCallback(this));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    Unused << SendResponse(
-      TVErrorResponse(nsITVServiceCallback::TV_ERROR_FAILURE));
-  }
-
-}
-
-void
-TVRequestParent::DoRequest(const TVGetChannelsRequest& aRequest)
-{
-  MOZ_ASSERT(mService);
-
-  nsresult rv = mService->GetChannels(aRequest.tunerId(), aRequest.sourceType(),
-                                      new TVRequestChannelGetterCallback(this));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    Unused << SendResponse(
-      TVErrorResponse(nsITVServiceCallback::TV_ERROR_FAILURE));
-  }
-}
-
-void
-TVRequestParent::DoRequest(const TVGetProgramsRequest& aRequest)
-{
-  MOZ_ASSERT(mService);
-
-  nsresult rv = mService->GetPrograms(aRequest.tunerId(),
-                                      aRequest.sourceType(),
-                                      aRequest.channelNumber(),
-                                      aRequest.startTime(),
-                                      aRequest.endTime(),
-                                      new TVRequestProgramGetterCallback(this));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    Unused << SendResponse(
-      TVErrorResponse(nsITVServiceCallback::TV_ERROR_FAILURE));
-  }
-}
-
-nsresult
-TVRequestParent::SendResponse(const TVIPCResponse& aResponse)
-{
-  if (NS_WARN_IF(!Send__delete__(this, aResponse))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  return NS_OK;
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/tv/ipc/TVParent.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_TVParent_h__
-#define mozilla_dom_TVParent_h__
-
-#include "mozilla/dom/PTVParent.h"
-#include "mozilla/dom/PTVRequestParent.h"
-#include "mozilla/dom/PTVTypes.h"
-#include "nsITVService.h"
-
-namespace mozilla {
-namespace dom {
-
-class TVParent final : public PTVParent
-                     , public nsITVSourceListener
-{
-public:
-  NS_DECL_THREADSAFE_ISUPPORTS
-  NS_DECL_NSITVSOURCELISTENER
-
-  TVParent();
-
-  bool Init();
-
-  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
-  virtual bool RecvPTVRequestConstructor(PTVRequestParent* aActor,
-                                         const TVIPCRequest& aRequest) override;
-
-  virtual PTVRequestParent*
-  AllocPTVRequestParent(const TVIPCRequest& aRequest) override;
-
-  virtual bool DeallocPTVRequestParent(PTVRequestParent* aActor) override;
-
-  virtual bool RecvRegisterSourceHandler(const nsString& aTunerId,
-                                         const nsString& aSourceType) override;
-
-  virtual bool RecvUnregisterSourceHandler(
-    const nsString& aTunerId, const nsString& aSourceType) override;
-
-private:
-  virtual ~TVParent();
-
-  nsCOMPtr<nsITVService> mService;
-};
-
-class TVRequestParent final : public PTVRequestParent,
-                              public nsISupports
-{
-  friend class TVParent;
-
-public:
-  NS_DECL_THREADSAFE_ISUPPORTS
-
-  explicit TVRequestParent(nsITVService* aService);
-
-  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
-  nsresult SendResponse(const TVIPCResponse& aResponse);
-
-private:
-  virtual ~TVRequestParent();
-
-  void DoRequest(const TVGetTunersRequest& aRequest);
-
-  void DoRequest(const TVSetSourceRequest& aRequest);
-
-  void DoRequest(const TVStartScanningChannelsRequest& aRequest);
-
-  void DoRequest(const TVStopScanningChannelsRequest& aRequest);
-
-  void DoRequest(const TVClearScannedChannelsCacheRequest& aRequest);
-
-  void DoRequest(const TVSetChannelRequest& aRequest);
-
-  void DoRequest(const TVGetChannelsRequest& aRequest);
-
-  void DoRequest(const TVGetProgramsRequest& aRequest);
-
-  nsCOMPtr<nsITVService> mService;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_TVParent_h__
--- a/dom/tv/moz.build
+++ b/dom/tv/moz.build
@@ -1,35 +1,29 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 EXPORTS.mozilla.dom += [
-    'ipc/TVChild.h',
-    'ipc/TVParent.h',
     'TVChannel.h',
     'TVListeners.h',
     'TVManager.h',
     'TVProgram.h',
     'TVServiceCallbacks.h',
     'TVServiceFactory.h',
     'TVServiceRunnables.h',
     'TVSource.h',
     'TVTuner.h',
     'TVTypes.h',
     'TVUtils.h',
 ]
 
 UNIFIED_SOURCES += [
-    'ipc/TVChild.cpp',
-    'ipc/TVIPCHelper.cpp',
-    'ipc/TVIPCService.cpp',
-    'ipc/TVParent.cpp',
     'TVChannel.cpp',
     'TVListeners.cpp',
     'TVManager.cpp',
     'TVProgram.cpp',
     'TVServiceCallbacks.cpp',
     'TVServiceFactory.cpp',
     'TVSource.cpp',
     'TVTuner.cpp',
@@ -41,27 +35,16 @@ XPIDL_SOURCES += [
     'nsITVSimulatorService.idl',
 ]
 
 EXTRA_COMPONENTS += [
     'TVSimulatorService.js',
     'TVSimulatorService.manifest',
 ]
 
-IPDL_SOURCES += [
-    'ipc/PTV.ipdl',
-    'ipc/PTVRequest.ipdl',
-    'ipc/PTVTypes.ipdlh'
-]
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
-    UNIFIED_SOURCES += [
-        'gonk/TVGonkService.cpp',
-    ];
-
 XPIDL_MODULE = 'dom_tv'
 
 MOCHITEST_MANIFESTS += ['test/mochitest/mochitest.ini']
 
 XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini']
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
--- a/dom/tv/nsITVService.idl
+++ b/dom/tv/nsITVService.idl
@@ -2,27 +2,22 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface nsIArray;
 
 %{C++
-#include "nsTArray.h"
-
 #define TV_TUNER_DATA_CID \
   { 0x1f36be28, 0xf9fe, 0x2dc3, { 0xbf, 0x2a, 0x17, 0x97, 0x93, 0x40, 0xff, 0xe1 } }
 #define TV_TUNER_DATA_CONTRACTID \
   "@mozilla.org/tv/tvtunerdata;1"
 %}
 
-[ref] native CStringArray(nsTArray<nsCString>);
-[ref] native ConstCStringArray(const nsTArray<nsCString>);
-
 /**
  * XPCOM component which acts as the container for tuner data.
  *
  * NOTE: Use do_CreateInstance() to create the Gecko provided implementation,
  * and then uses the setter functions to adjust the properties of the object
  * before passing it.
  */
 [scriptable, builtinclass, uuid(c6d39e86-022b-4db5-b0df-602abfbeac69)]
@@ -45,30 +40,25 @@ interface nsITVTunerData : nsISupports
    * http://seanyhlin.github.io/TV-Manager-API/ for available values.
    *
    * @param count       The number of supported source types.
    * @param sourceTypes An array of supported source types.
    */
   void getSupportedSourceTypes([optional] out unsigned long count,
                                [retval, array, size_is(count)] out string sourceTypes);
 
-  [noscript] CStringArray getSupportedSourceTypesByString();
-
   /**
    * Set the supported source types of the tuner. Please refer to
    * http://seanyhlin.github.io/TV-Manager-API/ for available values.
    *
    * @param count       The number of supported source types.
    * @param sourceTypes An array of supported source types.
    */
   void setSupportedSourceTypes(in unsigned long count,
                                [array, size_is(count)] in string sourceTypes);
-
-  [noscript] void setSupportedSourceTypesByString(
-                    in ConstCStringArray sourceTypes);
 };
 
 %{C++
 #define TV_CHANNEL_DATA_CID \
   { 0xdafe6881, 0x0964, 0xdb5b, { 0x59, 0xc6, 0x20, 0x0b, 0xa6, 0x59, 0xe6, 0x68 } }
 #define TV_CHANNEL_DATA_CONTRACTID \
   "@mozilla.org/tv/tvchanneldata;1"
 %}
@@ -122,55 +112,45 @@ interface nsITVProgramData : nsISupports
    * http://seanyhlin.github.io/TV-Manager-API/ for available values.
    *
    * @param count     The number of languages.
    * @param languages An array of languages.
    */
   void getAudioLanguages([optional] out unsigned long count,
                          [retval, array, size_is(count)] out string languages);
 
-  [noscript] CStringArray getAudioLanguagesByString();
-
-
   /**
    * Set the audio languages of the program. Please refer to
    * http://seanyhlin.github.io/TV-Manager-API/ for available values.
    *
    * @param count     The number of languages.
    * @param languages An array of languages.
    */
   void setAudioLanguages(in unsigned long count,
                          [array, size_is(count)] in string languages);
 
-  [noscript] void setAudioLanguagesByString(in ConstCStringArray languages);
-
   /**
    * Get the subtitle languages of the program. Please refer to
    * http://seanyhlin.github.io/TV-Manager-API/ for available values.
    *
    * @param count     The number of languages.
    * @param languages An array of languages.
    */
   void getSubtitleLanguages([optional] out unsigned long count,
                             [retval, array, size_is(count)] out string languages);
 
-  [noscript] CStringArray getSubtitleLanguagesByString();
-
   /**
    * Set the subtitle languages of the program. Please refer to
    * http://seanyhlin.github.io/TV-Manager-API/ for available values.
    *
    * @param count     The number of languages.
    * @param languages An array of languages.
    */
   void setSubtitleLanguages(in unsigned long count,
                             [array, size_is(count)] in string languages);
-
-  [noscript] void setSubtitleLanguagesByString(in ConstCStringArray languages);
-
 };
 
 [scriptable, builtinclass, uuid(47746633-1b77-4df4-9424-d315bde3d455)]
 interface nsITVSourceListener : nsISupports
 {
   /**
    * Called when a channel is detected through scanning (after
    * |nsITVService::startScanningChannels()| is invoked and probably before
@@ -223,39 +203,16 @@ interface nsITVSourceListener : nsISuppo
    */
   void notifyEITBroadcasted(in DOMString tunerId,
                             in DOMString sourceType,
                             in nsITVChannelData channelData,
                             [array, size_is(count)] in nsITVProgramData programDataList,
                             in unsigned long count);
 };
 
-%{C++
-#include "mozilla/layers/GonkNativeHandle.h"
-
-#define TV_GONK_NATIVE_HANDLE_DATA_CID \
-  { 0x1e72877a, 0xaacc, 0x425a, { 0xa3, 0x33, 0x85, 0xe1, 0xb2, 0x66, 0xcb, 0xb3 } }
-#define TV_GONK_NATIVE_HANDLE_DATA_CONTRACTID \
-  "@mozilla.org/tv/tvgonknativehandledata;1"
-%}
-
-[ref] native GonkNativeHandle(mozilla::layers::GonkNativeHandle);
-
-[scriptable, builtinclass, uuid(64acaf2e-3dc5-467a-962d-b4c2c920ec30)]
-interface nsITVGonkNativeHandleData : nsISupports
-{
-  /**
-   * A native handle associated with the TV stream.
-   *
-   * NOTE: It's only available for stream type |nsITVTunerData::TV_STREAM_TYPE_HW|.
-   */
-  [noscript]
-  attribute GonkNativeHandle handle;
-};
-
 [scriptable, builtinclass, uuid(01582a11-4707-455d-8d2a-2c8de8227dad)]
 interface nsITVServiceCallback : nsISupports
 {
   const unsigned short TV_ERROR_OK = 0;
   const unsigned short TV_ERROR_FAILURE = 1;
   const unsigned short TV_ERROR_INVALID_ARG = 2;
   const unsigned short TV_ERROR_NO_SIGNAL = 3;
   const unsigned short TV_ERROR_NOT_SUPPORTED = 4;
@@ -271,58 +228,55 @@ interface nsITVServiceCallback : nsISupp
    * Called when the operation succeeds.
    *
    * @param dataList A list of data.
    *                 An array of |nsITVTunerData| when used for |getTuners()|.
    *                 An array of |nsITVChannelData| ordered by the LCN (Logical
    *                 Channel Number) when used for |getChannels()|.
    *                 An array of |nsITVProgramData| ordered by the start time
    *                 for |getPrograms()|.
-   *                 An array of |nsITVGonkNativeHandleData| with only one
-   *                 element for |setSource()|.
    *                 An array of |nsITVChannelData| with only one element for
    *                 |setChannel()|.
+   *                 An array of |nsISupportsString| with only one element for
+   *                 |getOverlayId()|.
    *
    * NOTE: |nsIArray| is adopted to prevent this interface from being split into
    * multiple interfaces with different |notifySuccess|. Though the
    * implementation of TV service may need |nsIMutableArray| to fill in the
    * array, it doesn't seem necessary for other places to use the mutable one.
    */
   void notifySuccess([optional] in nsIArray dataList);
 };
 
 %{C++
 #define TV_SERVICE_CONTRACTID \
   "@mozilla.org/tv/tvservice;1"
 %}
 
-[scriptable, uuid(827f4e94-430a-47a6-954a-0c7470cfc5fe)]
+/**
+ * XPCOM component which interacts with the underlying TV components.
+ *
+ * NOTE: The implementation is expected to be done by TV vendors to cooperate
+ * with their own TV stack. The methods should not be called on any thread
+ * except for the XPCOM main thread.
+ *
+ * NOTE: The callbacks passing in the methods must be called asynchronously. In
+ * the implementation, actual runnable objects may need to be created and call
+ * the callback off of the runnables, after the function returns.
+ * TVServiceRunnables.h provides some ready-made runnables and could be used in
+ * the following way.
+ *
+ * nsCOMPtr<nsIRunnable> runnable =
+ *   new TVServiceNotifyRunnable(callback, dataList, optional errorCode);
+ * return NS_DispatchToCurrentThread(runnable);
+ */
+[scriptable, uuid(e52f93f1-6071-468b-a198-d8e6bc5ca348)]
 interface nsITVService : nsISupports
 {
-  /**
-   * Register a source listener.
-   *
-   * @param tunerId    The ID of the tuner.
-   * @param sourceType The source type to be used.
-   * @param listener   The listener to register.
-   */
-  void registerSourceListener(in DOMString tunerId,
-                              in DOMString sourceType,
-                              in nsITVSourceListener listener);
-
-  /**
-   * Unregister a source listener.
-   *
-   * @param tunerId    The ID of the tuner.
-   * @param sourceType The source type to be used.
-   * @param listener   The listener to register.
-   */
-  void unregisterSourceListener(in DOMString tunerId,
-                                in DOMString sourceType,
-                                in nsITVSourceListener listener);
+  attribute nsITVSourceListener sourceListener;
 
   /**
    * Get all tuners.
    *
    * @param callback   The callback object where either |notifyError| or
    *                   |notifySuccess|, which takes an array of
    *                   |nsITVTunerData|, is expected.
    */
@@ -419,9 +373,21 @@ interface nsITVService : nsISupports
    *                      expected.
    */
   void getPrograms(in DOMString tunerId,
                    in DOMString sourceType,
                    in DOMString channelNumber,
                    in unsigned long long startTime,
                    in unsigned long long endTime,
                    in nsITVServiceCallback callback);
+
+  /**
+   * Get the overlay ID of a given tuner.
+   *
+   * @param tunerId       The ID of the tuner.
+   * @param callback      The callback object where either |notifyError| or
+   *                      |notifySuccess|, which takes an array of
+   *                      |nsISupportsString| with only one element, is expected.
+   */
+  void getOverlayId(in DOMString tunerId,
+                    in nsITVServiceCallback callback);
 };
+
--- a/dom/tv/nsITVSimulatorService.idl
+++ b/dom/tv/nsITVSimulatorService.idl
@@ -11,67 +11,22 @@ interface mozIDOMWindow;
 #define TV_SIMULATOR_SERVICE_CONTRACTID\
   "@mozilla.org/tv/simulatorservice;1"
 %}
 
 [scriptable, uuid(3f670994-5915-415a-b906-7ead54bb3be1)]
 interface nsITVSimulatorService : nsITVService
 {
   /*
-   * Init the simulation data.
-   *
-   * @param mockedData    The preloaded mocked data in stringified JSON format.
-   */
-  void initData([optional] in DOMString mockedData);
-
-  /*
    * Get the URL of simulated video blob.
    *
    * @param tunerId       The ID of the tuner.
    * @param sourceType    The source type to be used.
    * @param channelNumber The LCN (Logical Channel Number) of the channel.
    * @param window        The window object of content.
    * @return blobUrl      The URL of created blob from local video file.
    */
   void getSimulatorVideoBlobURL(in DOMString tunerId,
                                 in DOMString sourceType,
                                 in DOMString channelNumber,
                                 in mozIDOMWindow window,
                                 [retval] out DOMString blobUrl);
-
-  /*
-   * Simulate some channels are scanned.
-   *
-   * @param tunerId       The ID of the tuner.
-   * @param sourceType    The source type to be used.
-   */
-  void simulateChannelScanned(in DOMString tunerId,
-                              in DOMString sourceType);
-
-  /*
-   * Simulate channel scanning complete.
-   *
-   * @param tunerId       The ID of the tuner.
-   * @param sourceType    The source type to be used.
-   */
-  void simulateChannelScanComplete(in DOMString tunerId,
-                                   in DOMString sourceType);
-
-  /*
-   * Simulate error occurs during channel scanning.
-   *
-   * @param tunerId       The ID of the tuner.
-   * @param sourceType    The source type to be used.
-   */
-  void simulateChannelScanError(in DOMString tunerId,
-                                in DOMString sourceType);
-
-  /*
-   * Simulate EIT broadcasted.
-   *
-   * @param tunerId       The ID of the tuner.
-   * @param sourceType    The source type to be used.
-   * @param channelNumber The LCN (Logical Channel Number) of the channel.
-   */
-  void simulateEITBroadcasted(in DOMString tunerId,
-                              in DOMString sourceType,
-                              in DOMString channelNumber);
 };
--- a/dom/tv/test/mochitest/head.js
+++ b/dom/tv/test/mochitest/head.js
@@ -1,45 +1,40 @@
 "use strict";
 
-function setupPrefsAndPermissions(aCallback) {
+function setupPrefsAndPermissions(callback) {
   setupPrefs(function() {
       SpecialPowers.pushPermissions([
         {"type":"tv", "allow":1, "context":document}
-      ], aCallback);
-  });
-}
-
-function setupPrefs(aCallback) {
-  SpecialPowers.pushPrefEnv({"set": [
-                              ["dom.tv.enabled", true],
-                              ["dom.ignore_webidl_scope_checks", true],
-                            ]}, function() {
-    aCallback();
+      ], callback);
   });
 }
 
-function removePrefsAndPermissions(aCallback) {
-  SpecialPowers.popPrefEnv(function() {
-    SpecialPowers.popPermissions(aCallback);
+function setupPrefs(callback) {
+  let xhr = new XMLHttpRequest;
+  let data;
+
+  xhr.open("GET", "./mock_data.json", false);
+  xhr.send(null);
+  if (xhr.status == 200) {
+    data = xhr.responseText;
+  }
+
+  SpecialPowers.pushPrefEnv({"set": [
+                              ["dom.tv.enabled", true],
+                              ["dom.ignore_webidl_scope_checks", true],
+                              ["dom.testing.tv_mock_data", data]
+                            ]}, function() {
+    callback();
   });
 }
 
-function prepareTest(aCallback) {
-  removePrefsAndPermissions(function() {
-    setupPrefsAndPermissions(function() {
-      initMockedData(aCallback);
-    });
+function removePrefsAndPermissions(callback) {
+  SpecialPowers.popPrefEnv(function() {
+    SpecialPowers.popPermissions(callback);
   });
 }
 
-function initMockedData(aCallback) {
-  let xhr = new XMLHttpRequest;
-  xhr.open("GET", "./mock_data.json", false);
-  xhr.send(null);
-  if (xhr.status == 200) {
-    var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('tv_chrome_script.js'));
-
-    gScript.addMessageListener('init-mocked-data-complete', aCallback);
-
-    gScript.sendAsyncMessage('init-mocked-data', xhr.responseText);
-  }
+function prepareTest(callback) {
+  removePrefsAndPermissions(function() {
+    setupPrefsAndPermissions(callback);
+  });
 }
--- a/dom/tv/test/mochitest/mochitest.ini
+++ b/dom/tv/test/mochitest/mochitest.ini
@@ -1,27 +1,20 @@
 [DEFAULT]
-skip-if = toolkit == "gonk"
 support-files =
   head.js
   mock_data.json
-  tv_chrome_script.js
 
 [test_tv_non_permitted_app.html]
 [test_tv_permitted_app.html]
 [test_tv_get_tuners.html]
 [test_tv_get_sources.html]
 [test_tv_get_channels.html]
 [test_tv_get_channels_during_scanning.html]
 [test_tv_get_programs.html]
 [test_tv_get_current_program.html]
 [test_tv_set_current_source.html]
 [test_tv_set_invalid_current_source.html]
 [test_tv_set_current_channel.html]
 [test_tv_set_current_channel_during_scanning.html]
 [test_tv_set_invalid_current_channel.html]
 [test_tv_scan_channels_stopped.html]
-skip-if = e10s || buildapp == 'b2g'
 [test_tv_scan_channels_completed.html]
-skip-if = e10s || buildapp == 'b2g'
-[test_tv_scan_channels_error.html]
-skip-if = e10s || buildapp == 'b2g'
-[test_tv_eit_broadcasted.html]
deleted file mode 100644
--- a/dom/tv/test/mochitest/test_tv_eit_broadcasted.html
+++ /dev/null
@@ -1,77 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test TVEITBroadcastedEvent for TV API</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-<script type="application/javascript" src="./head.js"></script>
-<script type="application/javascript">
-
-function runTest() {
-  ok('tv' in navigator, "navigator.tv should exist.");
-  var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('tv_chrome_script.js'));
-
-  navigator.tv.getTuners().then(
-    function(aTuners) {
-      ok(aTuners.length > 0, "Got at least 1 tuner.");
-
-      aTuners[0].getSources().then(
-        function(aSources) {
-          ok(aSources.length > 0, "Got at least 1 source.");
-          var source = aSources[0];
-
-          source.oneitbroadcasted = function(aEvent) {
-            info("Received EIT broadcasted event.");
-
-            var programs = aEvent.programs;
-            for (var i = 0; i < programs.length; i++) {
-              ok(programs[i], "Program " + i + " should be set.")
-            }
-
-            gScript.destroy();
-            SimpleTest.finish();
-          };
-
-          source.getChannels().then(
-            function(aChannels) {
-              ok(aChannels.length > 0, "Got at least 1 channel.");
-
-              gScript.sendAsyncMessage('trigger-eit-broadcasted',
-                                       { tunerId: aTuners[0].id,
-                                         sourceType: source.type,
-                                         channelNumber: aChannels[0].number });
-            },
-            function(aError) {
-              ok(false, "Error occurred when getting channels: " + aError);
-              gScript.destroy();
-              SimpleTest.finish();
-            }
-          );
-        },
-        function(aError) {
-          ok(false, "Error occurred when getting sources: " + aError);
-          gScript.destroy();
-          SimpleTest.finish();
-        }
-      );
-    },
-    function(aError) {
-      ok(false, "Error occurred when getting tuners: " + aError);
-      gScript.destroy();
-      SimpleTest.finish();
-    }
-  );
-}
-
-SimpleTest.waitForExplicitFinish();
-prepareTest(runTest);
-
-</script>
-</pre>
-</body>
-</html>
--- a/dom/tv/test/mochitest/test_tv_scan_channels_completed.html
+++ b/dom/tv/test/mochitest/test_tv_scan_channels_completed.html
@@ -11,68 +11,63 @@
 <pre id="test">
 <script type="application/javascript" src="./head.js"></script>
 <script type="application/javascript">
 
 function runTest() {
   ok('tv' in navigator, "navigator.tv should exist.");
 
   var isScannedEventFired = false;
-  var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('tv_chrome_script.js'));
-
+  
   navigator.tv.getTuners().then(
     function(aTuners) {
       ok(aTuners.length > 0, "Got at least 1 tuner.");
 
       aTuners[0].getSources().then(
         function(aSources) {
           ok(aSources.length > 0, "Got at least 1 source.");
           var source = aSources[0];
 
+          source.oneitbroadcasted = function(aEvent) {
+            info("Received EIT broadcasted event.");
+
+            var programs = aEvent.programs;
+            for (var i = 0; i < programs.length; i++) {
+              ok(programs[i], "Program " + i + " should be set.")
+            }
+          };
+
           source.onscanningstatechanged = function(aEvent) {
             if (aEvent.state === 'scanned') {
-              if (!isScannedEventFired) {
-                isScannedEventFired = true;
-                gScript.sendAsyncMessage('trigger-channel-scan-complete',
-                                         { tunerId: aTuners[0].id,
-                                           sourceType: source.type });
-              }
+              isScannedEventFired = true;
               info("Received channel scanned event.");
               ok(aEvent.channel, "Scanned channel should be set.");
             } else if (aEvent.state === 'completed') {
               ok(isScannedEventFired, "Received channel scanning completed event after channel scanned event.");
-              gScript.destroy();
               SimpleTest.finish();
             }
           };
 
           // TODO Bug 1088818 - Modify the behavior of channel scanning.
           source.startScanning({}).then(
-            function() {
-              gScript.sendAsyncMessage('trigger-channel-scanned',
-                                       { tunerId: aTuners[0].id,
-                                         sourceType: source.type });
-            },
+            function() {},
             function(aError) {
               ok(false, "Error occurred when starting scanning: " + aError);
-              gScript.destroy();
               SimpleTest.finish();
             }
           );
         },
         function(aError) {
           ok(false, "Error occurred when getting sources: " + aError);
-          gScript.destroy();
           SimpleTest.finish();
         }
       );
     },
     function(aError) {
       ok(false, "Error occurred when getting tuners: " + aError);
-      gScript.destroy();
       SimpleTest.finish();
     }
   );
 }
 
 SimpleTest.expectAssertions(0, 2);
 SimpleTest.waitForExplicitFinish();
 prepareTest(runTest);
deleted file mode 100644
--- a/dom/tv/test/mochitest/test_tv_scan_channels_error.html
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test channel scanning error for TV API</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-<script type="application/javascript" src="./head.js"></script>
-<script type="application/javascript">
-
-function runTest() {
-  ok('tv' in navigator, "navigator.tv should exist.");
-
-  var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('tv_chrome_script.js'));
-
-  navigator.tv.getTuners().then(
-    function(aTuners) {
-      ok(aTuners.length > 0, "Got at least 1 tuner.");
-
-      aTuners[0].getSources().then(
-        function(aSources) {
-          ok(aSources.length > 0, "Got at least 1 source.");
-          var source = aSources[0];
-
-          source.onscanningstatechanged = function(aEvent) {
-            if (aEvent.state === 'stopped') {
-              ok(true, "Received channel scanning stopped event.");
-              gScript.destroy();
-              SimpleTest.finish();
-            }
-          };
-
-          // TODO Bug 1088818 - Modify the behavior of channel scanning.
-          source.startScanning().then(
-            function() {
-              gScript.sendAsyncMessage('trigger-channel-scan-error',
-                                       { tunerId: aTuners[0].id,
-                                         sourceType: source.type });
-            },
-            function(aError) {
-              ok(false, "Error occurred when starting scanning: " + aError);
-              gScript.destroy();
-              SimpleTest.finish();
-            }
-          );
-        },
-        function(aError) {
-          ok(false, "Error occurred when getting sources: " + aError);
-          gScript.destroy();
-          SimpleTest.finish();
-        }
-      );
-    },
-    function(aError) {
-      ok(false, "Error occurred when getting tuners: " + aError);
-      gScript.destroy();
-      SimpleTest.finish();
-    }
-  );
-}
-
-SimpleTest.waitForExplicitFinish();
-prepareTest(runTest);
-
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/dom/tv/test/mochitest/tv_chrome_script.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-'use strict';
-
-const { classes: Cc, interfaces: Ci, manager: Cm, utils: Cu, results: Cr } = Components;
-
-Cu.import('resource://gre/modules/XPCOMUtils.jsm');
-
-addMessageListener('init-mocked-data', function(aData) {
-  var service = Cc["@mozilla.org/tv/tvservice;1"].getService(Ci.nsITVService);
-  try {
-    service.QueryInterface(Ci.nsITVSimulatorService).initData(aData);
-    sendAsyncMessage('init-mocked-data-complete');
-  } catch (e) {}
-});
-
-addMessageListener('trigger-channel-scanned', function(aData) {
-  var service = Cc["@mozilla.org/tv/tvservice;1"].getService(Ci.nsITVService);
-  try {
-    service.QueryInterface(Ci.nsITVSimulatorService).simulateChannelScanned(aData.tunerId, aData.sourceType);
-  } catch (e) {}
-});
-
-addMessageListener('trigger-channel-scan-complete', function(aData) {
-  var service = Cc["@mozilla.org/tv/tvservice;1"].getService(Ci.nsITVService);
-  try {
-    service.QueryInterface(Ci.nsITVSimulatorService).simulateChannelScanComplete(aData.tunerId, aData.sourceType);
-  } catch (e) {}
-});
-
-addMessageListener('trigger-channel-scan-error', function(aData) {
-  var service = Cc["@mozilla.org/tv/tvservice;1"].getService(Ci.nsITVService);
-  try {
-    service.QueryInterface(Ci.nsITVSimulatorService).simulateChannelScanError(aData.tunerId, aData.sourceType);
-  } catch (e) {}
-});
-
-addMessageListener('trigger-eit-broadcasted', function(aData) {
-  var service = Cc["@mozilla.org/tv/tvservice;1"].getService(Ci.nsITVService);
-  try {
-    service.QueryInterface(Ci.nsITVSimulatorService).simulateEITBroadcasted(aData.tunerId, aData.sourceType, aData.channelNumber);
-  } catch (e) {}
-});
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -388,22 +388,19 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMediaManagerService,
                                          MediaManager::GetInstance)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileConnectionService,
                                          NS_CreateMobileConnectionService)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITelephonyService,
                                          NS_CreateTelephonyService)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIVoicemailService,
                                          NS_CreateVoicemailService)
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITVService,
-                                         TVServiceFactory::AutoCreateTVService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(TVTunerData)
 NS_GENERIC_FACTORY_CONSTRUCTOR(TVChannelData)
 NS_GENERIC_FACTORY_CONSTRUCTOR(TVProgramData)
-NS_GENERIC_FACTORY_CONSTRUCTOR(TVGonkNativeHandleData)
 NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationDeviceManager)
 NS_GENERIC_FACTORY_CONSTRUCTOR(TextInputProcessor)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(FakeInputPortService,
                                          InputPortServiceFactory::CreateFakeInputPortService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(InputPortData)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPresentationService,
                                          NS_CreatePresentationService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationTCPSessionTransport)
@@ -851,21 +848,19 @@ NS_DEFINE_NAMED_CID(NS_POCKETSPHINX_SPEE
 #endif
 #ifdef MOZ_WEBSPEECH
 NS_DEFINE_NAMED_CID(NS_SYNTHVOICEREGISTRY_CID);
 #endif
 
 #ifdef ACCESSIBILITY
 NS_DEFINE_NAMED_CID(NS_ACCESSIBILITY_SERVICE_CID);
 #endif
-NS_DEFINE_NAMED_CID(TV_SERVICE_CID);
 NS_DEFINE_NAMED_CID(TV_TUNER_DATA_CID);
 NS_DEFINE_NAMED_CID(TV_CHANNEL_DATA_CID);
 NS_DEFINE_NAMED_CID(TV_PROGRAM_DATA_CID);
-NS_DEFINE_NAMED_CID(TV_GONK_NATIVE_HANDLE_DATA_CID);
 
 NS_DEFINE_NAMED_CID(FAKE_INPUTPORT_SERVICE_CID);
 NS_DEFINE_NAMED_CID(INPUTPORT_DATA_CID);
 
 NS_DEFINE_NAMED_CID(GECKO_MEDIA_PLUGIN_SERVICE_CID);
 
 NS_DEFINE_NAMED_CID(PRESENTATION_SERVICE_CID);
 NS_DEFINE_NAMED_CID(PRESENTATION_DEVICE_MANAGER_CID);
@@ -1157,21 +1152,19 @@ static const mozilla::Module::CIDEntry k
   { &kNS_GAMEPAD_TEST_CID, false, nullptr, GamepadServiceTestConstructor },
 #endif
 #ifdef ACCESSIBILITY
   { &kNS_ACCESSIBILITY_SERVICE_CID, false, nullptr, CreateA11yService },
 #endif
   { &kTELEPHONY_SERVICE_CID, false, nullptr, nsITelephonyServiceConstructor },
   { &kNS_MOBILE_CONNECTION_SERVICE_CID, false, NULL, nsIMobileConnectionServiceConstructor },
   { &kNS_VOICEMAIL_SERVICE_CID, false, nullptr, nsIVoicemailServiceConstructor },
-  { &kTV_SERVICE_CID, false, nullptr, nsITVServiceConstructor },
   { &kTV_TUNER_DATA_CID, false, nullptr, TVTunerDataConstructor },
   { &kTV_CHANNEL_DATA_CID, false, nullptr, TVChannelDataConstructor },
   { &kTV_PROGRAM_DATA_CID, false, nullptr, TVProgramDataConstructor },
-  { &kTV_GONK_NATIVE_HANDLE_DATA_CID, false, nullptr, TVGonkNativeHandleDataConstructor },
   { &kPRESENTATION_SERVICE_CID, false, nullptr, nsIPresentationServiceConstructor },
   { &kPRESENTATION_DEVICE_MANAGER_CID, false, nullptr, PresentationDeviceManagerConstructor },
   { &kPRESENTATION_TCP_SESSION_TRANSPORT_CID, false, nullptr, PresentationTCPSessionTransportConstructor },
   { &kTEXT_INPUT_PROCESSOR_CID, false, nullptr, TextInputProcessorConstructor },
   { &kFAKE_INPUTPORT_SERVICE_CID, false, nullptr, FakeInputPortServiceConstructor },
   { &kINPUTPORT_DATA_CID, false, nullptr, InputPortDataConstructor },
 #ifdef MOZ_B2G
   { &kNS_HARDWARE_KEY_HANDLER_CID, false, nullptr, nsIHardwareKeyHandlerConstructor },
@@ -1324,21 +1317,19 @@ static const mozilla::Module::ContractID
   { NS_GAMEPAD_TEST_CONTRACTID, &kNS_GAMEPAD_TEST_CID },
 #endif
   { MEDIAMANAGERSERVICE_CONTRACTID, &kNS_MEDIAMANAGERSERVICE_CID },
 #ifdef ACCESSIBILITY
   { "@mozilla.org/accessibilityService;1", &kNS_ACCESSIBILITY_SERVICE_CID },
   { "@mozilla.org/accessibleRetrieval;1", &kNS_ACCESSIBILITY_SERVICE_CID },
 #endif
   { TELEPHONY_SERVICE_CONTRACTID, &kTELEPHONY_SERVICE_CID },
-  { TV_SERVICE_CONTRACTID, &kTV_SERVICE_CID },
   { TV_TUNER_DATA_CONTRACTID, &kTV_TUNER_DATA_CID },
   { TV_CHANNEL_DATA_CONTRACTID, &kTV_CHANNEL_DATA_CID },
   { TV_PROGRAM_DATA_CONTRACTID, &kTV_PROGRAM_DATA_CID },
-  { TV_GONK_NATIVE_HANDLE_DATA_CONTRACTID, &kTV_GONK_NATIVE_HANDLE_DATA_CID },
   { "@mozilla.org/gecko-media-plugin-service;1",  &kGECKO_MEDIA_PLUGIN_SERVICE_CID },
   { NS_MOBILE_CONNECTION_SERVICE_CONTRACTID, &kNS_MOBILE_CONNECTION_SERVICE_CID },
   { NS_VOICEMAIL_SERVICE_CONTRACTID, &kNS_VOICEMAIL_SERVICE_CID },
   { PRESENTATION_SERVICE_CONTRACTID, &kPRESENTATION_SERVICE_CID },
   { PRESENTATION_DEVICE_MANAGER_CONTRACTID, &kPRESENTATION_DEVICE_MANAGER_CID },
   { PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID, &kPRESENTATION_TCP_SESSION_TRANSPORT_CID },
   { "@mozilla.org/text-input-processor;1", &kTEXT_INPUT_PROCESSOR_CID },
   { FAKE_INPUTPORT_SERVICE_CONTRACTID, &kFAKE_INPUTPORT_SERVICE_CID },