port domain util from chromium project

port domain util from chromium project