Skip to content

Commit

Permalink
Merge pull request mozilla#6 from GuanWen-Chen/TVDaemonIPC
Browse files Browse the repository at this point in the history
Bug 1263802 - Support communication between B2G and TV daemon process; a=jocheng
  • Loading branch information
xeonchen committed May 25, 2016
2 parents 9f233a9 + 4fdf45d commit 5601daf
Show file tree
Hide file tree
Showing 18 changed files with 3,511 additions and 18 deletions.
27 changes: 27 additions & 0 deletions dom/tv/TVLog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* -*- 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_TVLog_h
#define mozilla_dom_TVLog_h

#include "mozilla/Logging.h"

namespace mozilla {
namespace dom {

mozilla::LogModule*
GetTVLog()
{
static mozilla::LazyLogModule sTVLog("tv");
return sTVLog;
}

#define TV_LOG(...) MOZ_LOG(GetTVLog(), LogLevel::Debug, (__VA_ARGS__))

} // namespace dom
} // namespace mozilla

#endif
20 changes: 19 additions & 1 deletion dom/tv/TVServiceFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
namespace mozilla {
namespace dom {

#ifdef MOZ_WIDGET_GONK
static bool
HasDaemon()
{
static bool tested;
static bool hasDaemon;

if (MOZ_UNLIKELY(!tested)) {
hasDaemon = !access("/system/bin/tvd", X_OK);
tested = true;
}

return hasDaemon;
}
#endif

/* static */ already_AddRefed<nsITVService>
TVServiceFactory::AutoCreateTVService()
{
Expand All @@ -29,7 +45,9 @@ TVServiceFactory::AutoCreateTVService()
}

#ifdef MOZ_WIDGET_GONK
service = new TVGonkService();
if (HasDaemon()) {
service = new TVGonkService();
}
#endif

if (!service) {
Expand Down
18 changes: 16 additions & 2 deletions dom/tv/TVUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ namespace dom {
inline nsString
ToTVSourceTypeStr(const TVSourceType aSourceType)
{
MOZ_ASSERT(uint32_t(aSourceType) < ArrayLength(TVSourceTypeValues::strings));
MOZ_ASSERT(static_cast<uint32_t>(aSourceType) <
ArrayLength(TVSourceTypeValues::strings));

nsString str;
str.AssignASCII(TVSourceTypeValues::strings[uint32_t(aSourceType)].value);
str.AssignASCII(
TVSourceTypeValues::strings[static_cast<uint32_t>(aSourceType)].value);
return str;
}

Expand Down Expand Up @@ -133,6 +135,18 @@ ToTVChannelType(const nsAString& aStr)
return TVChannelType::EndGuard_;
}

inline nsString
ToTVChannelTypeStr(const TVChannelType aChannelType)
{
MOZ_ASSERT(static_cast<uint32_t>(aChannelType) <
ArrayLength(TVChannelTypeValues::strings));

nsString str;
str.AssignASCII(
TVChannelTypeValues::strings[static_cast<uint32_t>(aChannelType)].value);
return str;
}

} // namespace dom
} // namespace mozilla

Expand Down
Loading

0 comments on commit 5601daf

Please sign in to comment.