Canonical metrics on 3-manifolds and 4-manifolds