Refactor the python system_impl module.

Extract reusable code into a common library and isolate
environment-specific logic. This allows the upcoming python content
handler to implement only the base::-specific logic around RunLoop and
AsyncWaiter before injecting it.

R=qsr@chromium.org

Review URL: https://codereview.chromium.org/792843002