How to load static resources offline?
Posted:
Fri Mar 26, 2021 2:22 am
by WzCode1
In order to make the app load faster, I try to load static resources (css/js), etc., through local loading instead of loading server data through Url, but how do I intercept the loading server data?
Re: How to load static resources offline?
Posted:
Sun Mar 28, 2021 9:58 pm
by WzCode1
Thank you, I will look into it first!
Re: How to load static resources offline?
Posted:
Fri Apr 02, 2021 1:48 am
by WzCode1
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
Re: How to load static resources offline?
Posted:
Sun Jun 20, 2021 1:08 am
by prsolucoes
Hi,
Im with the sample problem. It dont enter on method OnRequest.
Do you solve it?
Thanks.