| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 automation API. | 5 // Custom bindings for the automation API. |
| 6 var automation = require('binding').Binding.create('automation'); | 6 var automation = require('binding').Binding.create('automation'); |
| 7 var automationInternal = | 7 var automationInternal = |
| 8 require('binding').Binding.create('automationInternal').generate(); | 8 require('binding').Binding.create('automationInternal').generate(); |
| 9 var eventBindings = require('event_bindings'); | 9 var eventBindings = require('event_bindings'); |
| 10 var Event = eventBindings.Event; | 10 var Event = eventBindings.Event; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 var targetTree = idToAutomationTree[id]; | 78 var targetTree = idToAutomationTree[id]; |
| 79 if (!targetTree) { | 79 if (!targetTree) { |
| 80 // If this is the first time we've gotten data for this tree, it will | 80 // If this is the first time we've gotten data for this tree, it will |
| 81 // contain all of the tree's data, so create a new tree which will be | 81 // contain all of the tree's data, so create a new tree which will be |
| 82 // bootstrapped from |data|. | 82 // bootstrapped from |data|. |
| 83 targetTree = new AutomationTree(pid, rid); | 83 targetTree = new AutomationTree(pid, rid); |
| 84 idToAutomationTree[id] = targetTree; | 84 idToAutomationTree[id] = targetTree; |
| 85 } | 85 } |
| 86 privates(targetTree).impl.update(data); | 86 privates(targetTree).impl.update(data); |
| 87 var eventType = data.eventType; | 87 var eventType = data.eventType; |
| 88 if (eventType == 'load_complete' || eventType == 'layout_complete') { | 88 if (eventType == 'loadComplete' || eventType == 'layoutComplete') { |
| 89 // If the tree wasn't available when getTree() was called, the callback will | 89 // If the tree wasn't available when getTree() was called, the callback will |
| 90 // have been cached in idToCallback, so call and delete it now that we | 90 // have been cached in idToCallback, so call and delete it now that we |
| 91 // have the complete tree. | 91 // have the complete tree. |
| 92 if (id in idToCallback) { | 92 if (id in idToCallback) { |
| 93 for (var i = 0; i < idToCallback[id].length; i++) { | 93 for (var i = 0; i < idToCallback[id].length; i++) { |
| 94 var callback = idToCallback[id][i]; | 94 var callback = idToCallback[id][i]; |
| 95 callback(targetTree); | 95 callback(targetTree); |
| 96 } | 96 } |
| 97 delete idToCallback[id]; | 97 delete idToCallback[id]; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 }); | 100 }); |
| 101 | 101 |
| 102 exports.binding = automation.generate(); | 102 exports.binding = automation.generate(); |
| OLD | NEW |