Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(746)

Side by Side Diff: chrome/renderer/resources/extensions/send_request.js

Issue 9918006: Split SchemaGeneratedBindings up into smaller, more targetted native handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 sgb = requireNative('schema_generated_bindings'); 6 var natives = requireNative('sendRequest');
7 var GetNextRequestId = sgb.GetNextRequestId;
8 var StartRequest = sgb.StartRequest;
9 7
10 // Callback handling. 8 // Callback handling.
11 var requests = []; 9 var requests = [];
12 chromeHidden.handleResponse = function(requestId, name, 10 chromeHidden.handleResponse = function(requestId, name,
13 success, response, error) { 11 success, response, error) {
14 try { 12 try {
15 var request = requests[requestId]; 13 var request = requests[requestId];
16 if (success) { 14 if (success) {
17 delete chrome.extension.lastError; 15 delete chrome.extension.lastError;
18 } else { 16 } else {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 var request = prepareRequest(args, argSchemas); 103 var request = prepareRequest(args, argSchemas);
106 if (opt_args.customCallback) { 104 if (opt_args.customCallback) {
107 request.customCallback = opt_args.customCallback; 105 request.customCallback = opt_args.customCallback;
108 } 106 }
109 // JSON.stringify doesn't support a root object which is undefined. 107 // JSON.stringify doesn't support a root object which is undefined.
110 if (request.args === undefined) 108 if (request.args === undefined)
111 request.args = null; 109 request.args = null;
112 110
113 var sargs = opt_args.noStringify ? 111 var sargs = opt_args.noStringify ?
114 request.args : chromeHidden.JSON.stringify(request.args); 112 request.args : chromeHidden.JSON.stringify(request.args);
115 var nativeFunction = opt_args.nativeFunction || StartRequest; 113 var nativeFunction = opt_args.nativeFunction || natives.StartRequest;
116 114
117 var requestId = GetNextRequestId(); 115 var requestId = natives.GetNextRequestId();
118 request.id = requestId; 116 request.id = requestId;
119 requests[requestId] = request; 117 requests[requestId] = request;
120 var hasCallback = 118 var hasCallback =
121 (request.callback || opt_args.customCallback) ? true : false; 119 (request.callback || opt_args.customCallback) ? true : false;
122 return nativeFunction(functionName, sargs, requestId, hasCallback, 120 return nativeFunction(functionName, sargs, requestId, hasCallback,
123 opt_args.forIOThread); 121 opt_args.forIOThread);
124 } 122 }
125 123
126 exports.sendRequest = sendRequest; 124 exports.sendRequest = sendRequest;
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/schema_generated_bindings.js ('k') | chrome/renderer/resources/extensions/set_icon.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698