Create complete URLRequestContextGetter for URLRequestFetchJob

The trivial one is causing crashes.
This commit is contained in:
Cheng Zhao 2016-03-10 14:39:40 +09:00
parent e3af5de7d7
commit 89f17e0baf
5 changed files with 47 additions and 31 deletions

View file

@ -16,7 +16,9 @@ namespace internal {
namespace {
// The callback which is passed to |handler|.
void HandlerCallback(const ResponseCallback& callback, mate::Arguments* args) {
void HandlerCallback(const BeforeStartCallback& before_start,
const ResponseCallback& callback,
mate::Arguments* args) {
// If there is no argument passed then we failed.
v8::Local<v8::Value> value;
if (!args->GetNext(&value)) {
@ -26,6 +28,9 @@ void HandlerCallback(const ResponseCallback& callback, mate::Arguments* args) {
return;
}
// Give the job a chance to parse V8 value.
before_start.Run(args->isolate(), value);
// Pass whatever user passed to the actaul request job.
V8ValueConverter converter;
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
@ -40,15 +45,17 @@ void HandlerCallback(const ResponseCallback& callback, mate::Arguments* args) {
void AskForOptions(v8::Isolate* isolate,
const JavaScriptHandler& handler,
net::URLRequest* request,
const BeforeStartCallback& before_start,
const ResponseCallback& callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Context::Scope context_scope(context);
handler.Run(request,
mate::ConvertToV8(isolate,
base::Bind(&HandlerCallback, callback)));
handler.Run(
request,
mate::ConvertToV8(isolate,
base::Bind(&HandlerCallback, before_start, callback)));
}
bool IsErrorOptions(base::Value* value, int* error) {