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

Side by Side Diff: chrome/renderer/resources/extensions/experimental.socket_custom_bindings.js

Issue 9386001: Implement a module system for the extension bindings JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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 // Custom bindings for the experimental.socket API. 5 // Custom bindings for the experimental.socket API.
6 6
7 (function() { 7 var experimentalSocketNatives = requireNative('experimental_socket');
8 native function GetChromeHidden(); 8 var GetNextSocketEventId = experimentalSocketNatives.GetNextSocketEventId;
9 native function GetNextSocketEventId();
10 9
11 var chromeHidden = GetChromeHidden(); 10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
12 11
13 chromeHidden.registerCustomHook('experimental.socket', function(api) { 12 chromeHidden.registerCustomHook('experimental.socket', function(api) {
14 var apiFunctions = api.apiFunctions; 13 var apiFunctions = api.apiFunctions;
15 var sendRequest = api.sendRequest; 14 var sendRequest = api.sendRequest;
16 15
17 apiFunctions.setHandleRequest('create', function() { 16 apiFunctions.setHandleRequest('create', function() {
18 var args = arguments; 17 var args = arguments;
19 if (args.length > 3 && args[3] && args[3].onEvent) { 18 if (args.length > 3 && args[3] && args[3].onEvent) {
20 var id = GetNextSocketEventId(); 19 var id = GetNextSocketEventId();
21 args[3].srcId = id; 20 args[3].srcId = id;
(...skipping 27 matching lines...) Expand all
49 default: 48 default:
50 console.error('Unexpected SocketEvent, type ' + event.type); 49 console.error('Unexpected SocketEvent, type ' + event.type);
51 break; 50 break;
52 } 51 }
53 if (event.isFinalEvent) { 52 if (event.isFinalEvent) {
54 delete chromeHidden.socket.handlers[event.srcId]; 53 delete chromeHidden.socket.handlers[event.srcId];
55 } 54 }
56 } 55 }
57 }); 56 });
58 }); 57 });
59
60 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698