Factor out some code into a new history provider.