Add callbacks for set_global_engine

This adds functionality where a class can monitor for the global
engine changing.

This is useful for a class that caches the global engine and
wants to know when its cached global engine isn't valid anymore.

Part of fix for bug 1179259

Change-Id: I5736a05308c63de9fccb8af7720ddd70530f4270
Merge "Add callbacks for set_global_engine"