by WzCode1 » Fri Apr 02, 2021 1:48 am
In the process of implementing offline loading of static resources, I inherited RequestDumpResourceProvider: public CefResourceManager::Provider, this class, but the OnRequest function is not called. What is the reason?
class RequestDumpResourceProvider : public CefResourceManager::Provider
{
public:
explicit RequestDumpResourceProvider(const std::string& url) : url_(url) {
DCHECK(!url.empty());
}
bool OnRequest(scoped_refptr<CefResourceManager::Request> request) OVERRIDE {
CEF_REQUIRE_IO_THREAD();
const std::string& url = request->url();
if (url != url_) {
// Not handled by this provider.
return false;
}
const std::string& dump = DumpRequestContents(request->request());
std::string str =
"<html><body bgcolor=\"white\"><pre>" + dump + "</pre></body></html>";
CefRefPtr<CefStreamReader> stream = CefStreamReader::CreateForData(
static_cast<void*>(const_cast<char*>(str.c_str())), str.size());
DCHECK(stream.get());
request->Continue(new CefStreamResourceHandler("text/html", stream));
return true;
}
private:
std::string url_;
//CefResourceManager::UrlFilter fileterUrl;
DISALLOW_COPY_AND_ASSIGN(RequestDumpResourceProvider);
};
Which does not call the OnRequest function