Home | History | Annotate | Download | only in common
      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
      3 // found in the LICENSE file.
      4 
      5 // Developer tools consist of the following parts:
      6 //
      7 // DevToolsAgent lives in the renderer of an inspected page and provides access
      8 // to the pages resources, DOM, v8 etc. by means of IPC messages.
      9 //
     10 // DevToolsClient is a thin delegate that lives in the tools front-end
     11 // renderer and converts IPC messages to frontend method calls and allows the
     12 // frontend to send messages to the DevToolsAgent.
     13 //
     14 // All the messages are routed through browser process. There is a
     15 // DevToolsManager living in the browser process that is responsible for
     16 // routing logistics. It is also capable of sending direct messages to the
     17 // agent rather than forwarding messages between agents and clients only.
     18 //
     19 // Chain of communication between the components may be described by the
     20 // following diagram:
     21 //  ----------------------------
     22 // | (tools frontend            |
     23 // | renderer process)          |
     24 // |                            |            --------------------
     25 // |tools    <--> DevToolsClient+<-- IPC -->+ (browser process)  |
     26 // |frontend                    |           |                    |
     27 //  ----------------------------             ---------+----------
     28 //                                                    ^
     29 //                                                    |
     30 //                                                   IPC
     31 //                                                    |
     32 //                                                    v
     33 //                          --------------------------+--------
     34 //                         | inspected page <--> DevToolsAgent |
     35 //                         |                                   |
     36 //                         | (inspected page renderer process) |
     37 //                          -----------------------------------
     38 //
     39 // This file describes developer tools message types.
     40 
     41 // Multiply-included message file, no standard include guard.
     42 #include <map>
     43 #include <string>
     44 
     45 #include "content/common/content_export.h"
     46 #include "content/public/common/common_param_traits.h"
     47 #include "content/public/common/console_message_level.h"
     48 #include "ipc/ipc_message_macros.h"
     49 
     50 #undef IPC_MESSAGE_EXPORT
     51 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
     52 
     53 #define IPC_MESSAGE_START DevToolsMsgStart
     54 
     55 // These are messages sent from DevToolsAgent to DevToolsClient through the
     56 // browser.
     57 // WebKit-level transport.
     58 IPC_MESSAGE_ROUTED1(DevToolsClientMsg_DispatchOnInspectorFrontend,
     59                     std::string /* message */)
     60 
     61 //-----------------------------------------------------------------------------
     62 // These are messages sent from DevToolsClient to DevToolsAgent through the
     63 // browser.
     64 // Tells agent that there is a client host connected to it.
     65 IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_Attach,
     66                     std::string /* host_id */)
     67 
     68 // Tells agent that a client host was disconnected from another agent and
     69 // connected to this one.
     70 IPC_MESSAGE_ROUTED2(DevToolsAgentMsg_Reattach,
     71                     std::string /* host_id */,
     72                     std::string /* agent_state */)
     73 
     74 // Tells agent that there is no longer a client host connected to it.
     75 IPC_MESSAGE_ROUTED0(DevToolsAgentMsg_Detach)
     76 
     77 // WebKit-level transport.
     78 IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_DispatchOnInspectorBackend,
     79                     std::string /* message */)
     80 
     81 // Inspect element with the given coordinates.
     82 IPC_MESSAGE_ROUTED3(DevToolsAgentMsg_InspectElement,
     83                     std::string /* host_id */,
     84                     int /* x */,
     85                     int /* y */)
     86 
     87 // Add message to the devtools console.
     88 IPC_MESSAGE_ROUTED2(DevToolsAgentMsg_AddMessageToConsole,
     89                     content::ConsoleMessageLevel /* level */,
     90                     std::string /* message */)
     91 
     92 // Worker DevTools agent should resume worker execution.
     93 IPC_MESSAGE_ROUTED0(DevToolsAgentMsg_ResumeWorkerContext)
     94 
     95 //-----------------------------------------------------------------------------
     96 // These are messages sent from the browser to the renderer.
     97 
     98 // RenderViewHostDelegate::RenderViewCreated method sends this message to a
     99 // new renderer to notify it that it will host developer tools UI and should
    100 // set up all neccessary bindings and create DevToolsClient instance that
    101 // will handle communication with inspected page DevToolsAgent.
    102 IPC_MESSAGE_ROUTED0(DevToolsMsg_SetupDevToolsClient)
    103 
    104 
    105 //-----------------------------------------------------------------------------
    106 // These are messages sent from the renderer to the browser.
    107 
    108 // Transport from Inspector frontend to frontend host.
    109 IPC_MESSAGE_ROUTED1(DevToolsHostMsg_DispatchOnEmbedder,
    110                     std::string /* message */)
    111 
    112 // Updates agent runtime state stored in devtools manager in order to support
    113 // cross-navigation instrumentation.
    114 IPC_MESSAGE_ROUTED1(DevToolsHostMsg_SaveAgentRuntimeState,
    115                     std::string /* state */)
    116 
    117 //-----------------------------------------------------------------------------
    118 // These are messages sent from the GPU process to the inspected renderer.
    119 
    120 IPC_STRUCT_BEGIN(GpuTaskInfo)
    121   IPC_STRUCT_MEMBER(double, timestamp)
    122   IPC_STRUCT_MEMBER(int, phase)
    123   IPC_STRUCT_MEMBER(bool, foreign)
    124   IPC_STRUCT_MEMBER(uint64, gpu_memory_used_bytes)
    125   IPC_STRUCT_MEMBER(uint64, gpu_memory_limit_bytes)
    126 IPC_STRUCT_END()
    127 
    128 // Recorded events are passed in chunks to the renderer process.
    129 IPC_MESSAGE_ROUTED1(DevToolsAgentMsg_GpuTasksChunk,
    130                     std::vector<GpuTaskInfo> /* gpu_tasks */)
    131 
    132 //-----------------------------------------------------------------------------
    133 // These are messages sent from the inspected page renderer to the worker
    134 // renderer.
    135