Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 5 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 6 var natives = requireNative('sendRequest'); | 6 var natives = requireNative('sendRequest'); |
| 7 | 7 |
| 8 // Callback handling. | 8 // Callback handling. |
| 9 var requests = []; | 9 var requests = []; |
| 10 chromeHidden.handleResponse = function(requestId, name, | 10 chromeHidden.handleResponse = function(requestId, name, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 if (!opt_args) | 100 if (!opt_args) |
| 101 opt_args = {}; | 101 opt_args = {}; |
| 102 var request = prepareRequest(args, argSchemas); | 102 var request = prepareRequest(args, argSchemas); |
| 103 if (opt_args.customCallback) { | 103 if (opt_args.customCallback) { |
| 104 request.customCallback = opt_args.customCallback; | 104 request.customCallback = opt_args.customCallback; |
| 105 } | 105 } |
| 106 // JSON.stringify doesn't support a root object which is undefined. | 106 // JSON.stringify doesn't support a root object which is undefined. |
| 107 if (request.args === undefined) | 107 if (request.args === undefined) |
| 108 request.args = null; | 108 request.args = null; |
| 109 | 109 |
| 110 var sargs = opt_args.noStringify ? | 110 // TODO(asargent) - convert all optional native functions to accept raw |
| 111 request.args : chromeHidden.JSON.stringify(request.args); | 111 // v8 values instead of expecting JSON strings. |
| 112 var doStringify = false; | |
| 113 if (opt_args.nativeFunction && !opt_args.noStringify) | |
|
asargent_no_longer_on_chrome
2012/05/04 22:42:22
FYI, this line fixes browser test failures I was g
| |
| 114 doStringify = true; | |
| 115 var requestArgs = doStringify ? | |
| 116 chromeHidden.JSON.stringify(request.args) : request.args; | |
| 112 var nativeFunction = opt_args.nativeFunction || natives.StartRequest; | 117 var nativeFunction = opt_args.nativeFunction || natives.StartRequest; |
| 113 | 118 |
| 114 var requestId = natives.GetNextRequestId(); | 119 var requestId = natives.GetNextRequestId(); |
| 115 request.id = requestId; | 120 request.id = requestId; |
| 116 requests[requestId] = request; | 121 requests[requestId] = request; |
| 117 var hasCallback = | 122 var hasCallback = |
| 118 (request.callback || opt_args.customCallback) ? true : false; | 123 (request.callback || opt_args.customCallback) ? true : false; |
| 119 return nativeFunction(functionName, sargs, requestId, hasCallback, | 124 return nativeFunction(functionName, requestArgs, requestId, hasCallback, |
| 120 opt_args.forIOThread); | 125 opt_args.forIOThread); |
| 121 } | 126 } |
| 122 | 127 |
| 123 exports.sendRequest = sendRequest; | 128 exports.sendRequest = sendRequest; |
| OLD | NEW |