HomePhabricator

Add MobileFrontend.Context service
535f18b159b8Unpublished

Authored by phuedx on Aug 17 2016, 10:04 AM.

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Add MobileFrontend.Context service

This service allows us to break apart classes that rely heavily on
MobileContext::singleton, i.e. MobileFrontendHooks, and also to extract
real services from MobileContext while maintaining compatibility with
existing clients, e.g. DeviceFormFactorDetector (see T143891).

To be clear, this service should be considered temporary.

Notes:

  • Because MobileContext::singleton is used everywhere, there were calls to MobileContext::setInstance in several test cases which were meant to reset the object's state. Create the ::resetServiceForTesting method which service this use case.

Changes:

  • Make MobileContext::singleton return the MobileFrontend.Context service, if the singleton instance hasn't been set
  • Make MobileContext accept instance of Config at construction, which can then be returned MobileContext#getMFConfig
  • Update test suites to use MobileContext::resetServiceForTesting
  • Deprecate MobileContext::singleton, ::setInstanceForTesting, and ::resetServiceForTesting as they are superseded by the service

Co-Author: Joaquín Hernández <jhernandez@wikimedia.org>
Bug: T143189
Bug: T143875
Change-Id: I8d57f485d5814dd8ecce151a1064dd3f6b20f73b