The deal marks the end of years of uncertainty about the fate of the popular video-sharing platform in the United States.