EntryArray.idl revision dcc8cf2e65d1aa555cce12431a16547e66b469ee
18a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block/* 28a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * Copyright (C) 2010 Google Inc. All rights reserved. 38a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * 48a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * Redistribution and use in source and binary forms, with or without 58a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * modification, are permitted provided that the following conditions are 68a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * met: 78a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * 88a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * * Redistributions of source code must retain the above copyright 98a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * notice, this list of conditions and the following disclaimer. 108a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * * Redistributions in binary form must reproduce the above 118a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * copyright notice, this list of conditions and the following disclaimer 128a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * in the documentation and/or other materials provided with the 138a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * distribution. 148a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * * Neither the name of Google Inc. nor the names of its 158a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * contributors may be used to endorse or promote products derived from 168a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * this software without specific prior written permission. 178a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * 188a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 198a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 208a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 218a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 228a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 238a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 248a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 258a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 268a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 278a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 288a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 298a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block */ 308a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 318a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block/** 328a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * @fileoverview Injects "injected" object into the inspectable page. 338a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block */ 348a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 358a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 368a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Blockvar InspectorControllerDispatcher = {}; 378a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 388a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block/** 398a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * Main dispatch method, all calls from the host to InspectorController go 408a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * through this one. 418a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * @param {string} functionName Function to call 428a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * @param {string} json_args JSON-serialized call parameters. 438a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * @return {string} JSON-serialized result of the dispatched call. 448a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block */ 458a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve BlockInspectorControllerDispatcher.dispatch = function(functionName, json_args) 468a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block{ 478a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block var params = JSON.parse(json_args); 488a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block InspectorBackend[functionName].apply(InspectorBackend, params); 498a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block}; 508a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 518a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block/** 528a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * Special controller object for APU related messages. Outgoing messages 538a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * are sent to this object if the ApuAgentDispatcher is enabled. 548a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block **/ 558a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Blockvar ApuAgentDispatcher = { enabled : false }; 568a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 578a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block/** 588a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * Dispatches messages to APU. This filters and transforms 598a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * outgoing messages that are used by APU. 608a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * @param {string} method name of the dispatch method. 618a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block **/ 628a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve BlockApuAgentDispatcher.dispatchToApu = function(method, args) 638a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block{ 648a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block if (method !== "addRecordToTimeline" && method !== "updateResource" && method !== "addResource") 658a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block return; 668a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block // TODO(knorton): Transform args so they can be used 678a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block // by APU. 688a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block DevToolsAgentHost.dispatchToApu(JSON.stringify(args)); 698a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block}; 708a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 718a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block/** 728a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * This is called by the InspectorFrontend for serialization. 738a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * We serialize the call and send it to the client over the IPC 748a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block * using dispatchOut bound method. 758a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block */ 768a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Blockfunction dispatch(method, var_args) { 778a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block // Handle all messages with non-primitieve arguments here. 788a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block var args = Array.prototype.slice.call(arguments); 798a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 808a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block if (method === "inspectedWindowCleared" || method === "reset" || method === "setAttachedWindow") { 818a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block // Filter out messages we don't need here. 828a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block // We do it on the sender side since they may have non-serializable 838a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block // parameters. 848a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block return; 858a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block } 868a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 878a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block // Sniff some inspector controller state changes in order to support 888a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block // cross-navigation instrumentation. Keep names in sync with 898a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block // webdevtoolsagent_impl. 908a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block if (method === "timelineProfilerWasStarted") 918a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block DevToolsAgentHost.runtimeFeatureStateChanged("timeline-profiler", true); 928a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block else if (method === "timelineProfilerWasStopped") 938a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block DevToolsAgentHost.runtimeFeatureStateChanged("timeline-profiler", false); 948a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block else if (method === "resourceTrackingWasEnabled") 958a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block DevToolsAgentHost.runtimeFeatureStateChanged("resource-tracking", true); 968a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block else if (method === "resourceTrackingWasDisabled") 978a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block DevToolsAgentHost.runtimeFeatureStateChanged("resource-tracking", false); 988a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 998a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block if (ApuAgentDispatcher.enabled) { 1008a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block ApuAgentDispatcher.dispatchToApu(method, args); 1018a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block return; 1028a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block } 1038a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block 1048a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block var call = JSON.stringify(args); 1058a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block DevToolsAgentHost.dispatch(call); 1068a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block}; 107dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 108dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockfunction close() { 109dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // This method is called when InspectorFrontend closes in layout tests. 110dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 111dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 112dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockfunction inspectedPageDestroyed() { 113dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 114