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.
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.
};
void AdapterRequestJob::Start() {
DCHECK(!real_job_.get());
- content::BrowserThread::PostTask(
- content::BrowserThread::UI,
- FROM_HERE,
- base::Bind(&AdapterRequestJob::GetJobTypeInUI,
- weak_factory_.GetWeakPtr()));
+ GetJobType();
}
void AdapterRequestJob::Kill() {
ProtocolHandler* default_protocol_handler() { return protocol_handler_; }
// Override this function to determine which job should be started.
- virtual void GetJobTypeInUI() = 0;
+ virtual void GetJobType() = 0;
void CreateErrorJobAndStart(int error_code);
void CreateStringJobAndStart(const std::string& mime_type,