get jsprotocolhandler in IO thread

This commit is contained in:
Robo 2015-07-22 21:54:12 +05:30
parent a1ec07e07e
commit 97c90d31d3
3 changed files with 11 additions and 10 deletions

View file

@ -80,16 +80,13 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
registry_(registry) {
}
// AdapterRequestJob:
void GetJobTypeInUI() override {
void GetJobTypeInUI(const Protocol::JsProtocolHandler& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
v8::Locker locker(registry_->isolate());
v8::HandleScope handle_scope(registry_->isolate());
// Call the JS handler.
Protocol::JsProtocolHandler callback =
registry_->GetProtocolHandler(request()->url().scheme());
v8::Local<v8::Value> result = callback.Run(request());
// Determine the type of the job we are going to create.
@ -172,6 +169,14 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
GetWeakPtr(), net::ERR_NOT_IMPLEMENTED));
}
// AdapterRequestJob:
void GetJobType() override {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&CustomProtocolRequestJob::GetJobTypeInUI,
base::Unretained(this),
registry_->GetProtocolHandler(request()->url().scheme())));
}
private:
Protocol* registry_; // Weak, the Protocol class is expected to live forever.
};