I finally use the code in tests/unittests/resource_manager_unittest.cc and cut and paste the OneShotProvider class and the ProviderDestructHelper classes in my source code, then I can easily insert content by calling the following code:
ProviderDestructHelper destruct_helper(1);
fResourceManager->AddProvider(
new OneShotProvider(content,
destruct_helper.callback()),
0, std::string());
All the problems I had with my previous implementation based on the URI are now gone! codelimit, it can interest you also because it addresses your question about how to remove the provider.