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 // Defines messages between the browser and worker process, as well as between 6 // the renderer and worker process. 7 8 // Multiply-included message file, hence no include guard. 9 10 #include <string> 11 #include <utility> 12 #include <vector> 13 14 #include "base/basictypes.h" 15 #include "base/strings/string16.h" 16 #include "content/common/content_export.h" 17 #include "content/common/content_param_traits.h" 18 #include "ipc/ipc_message_macros.h" 19 #include "ipc/ipc_message_utils.h" 20 #include "url/gurl.h" 21 22 #undef IPC_MESSAGE_EXPORT 23 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT 24 #define IPC_MESSAGE_START WorkerMsgStart 25 26 // Parameters structure for WorkerHostMsg_PostConsoleMessageToWorkerObject, 27 // which has too many data parameters to be reasonably put in a predefined 28 // IPC message. The data members directly correspond to parameters of 29 // WebWorkerClient::postConsoleMessageToWorkerObject() 30 IPC_STRUCT_BEGIN(WorkerHostMsg_PostConsoleMessageToWorkerObject_Params) 31 IPC_STRUCT_MEMBER(int, source_identifier) 32 IPC_STRUCT_MEMBER(int, message_type) 33 IPC_STRUCT_MEMBER(int, message_level) 34 IPC_STRUCT_MEMBER(base::string16, message) 35 IPC_STRUCT_MEMBER(int, line_number) 36 IPC_STRUCT_MEMBER(base::string16, source_url) 37 IPC_STRUCT_END() 38 39 // Parameter structure for WorkerProcessMsg_CreateWorker. 40 IPC_STRUCT_BEGIN(WorkerProcessMsg_CreateWorker_Params) 41 IPC_STRUCT_MEMBER(GURL, url) 42 IPC_STRUCT_MEMBER(base::string16, name) 43 IPC_STRUCT_MEMBER(base::string16, content_security_policy) 44 IPC_STRUCT_MEMBER(blink::WebContentSecurityPolicyType, security_policy_type) 45 IPC_STRUCT_MEMBER(bool, pause_on_start) 46 IPC_STRUCT_MEMBER(int, route_id) 47 IPC_STRUCT_END() 48 49 //----------------------------------------------------------------------------- 50 // WorkerProcess messages 51 // These are messages sent from the browser to the worker process. 52 IPC_MESSAGE_CONTROL1(WorkerProcessMsg_CreateWorker, 53 WorkerProcessMsg_CreateWorker_Params) 54 55 //----------------------------------------------------------------------------- 56 // WorkerProcessHost messages 57 // These are messages sent from the worker process to the browser process. 58 59 // Sent by the worker process to check whether access to web databases is 60 // allowed. 61 IPC_SYNC_MESSAGE_CONTROL5_1(WorkerProcessHostMsg_AllowDatabase, 62 int /* worker_route_id */, 63 GURL /* origin url */, 64 base::string16 /* database name */, 65 base::string16 /* database display name */, 66 unsigned long /* estimated size */, 67 bool /* result */) 68 69 // Sent by the worker process to check whether access to file system is allowed. 70 IPC_SYNC_MESSAGE_CONTROL2_1(WorkerProcessHostMsg_RequestFileSystemAccessSync, 71 int /* worker_route_id */, 72 GURL /* origin url */, 73 bool /* result */) 74 75 // Sent by the worker process to check whether access to IndexedDB is allowed. 76 IPC_SYNC_MESSAGE_CONTROL3_1(WorkerProcessHostMsg_AllowIndexedDB, 77 int /* worker_route_id */, 78 GURL /* origin url */, 79 base::string16 /* database name */, 80 bool /* result */) 81 82 // Sent by the worker process to request being killed. 83 IPC_SYNC_MESSAGE_CONTROL0_0(WorkerProcessHostMsg_ForceKillWorker) 84 85 86 //----------------------------------------------------------------------------- 87 // Worker messages 88 // These are messages sent from the renderer process to the worker process. 89 IPC_MESSAGE_ROUTED0(WorkerMsg_TerminateWorkerContext) 90 91 IPC_MESSAGE_ROUTED2(WorkerMsg_Connect, 92 int /* sent_message_port_id */, 93 int /* routing_id */) 94 95 IPC_MESSAGE_ROUTED0(WorkerMsg_WorkerObjectDestroyed) 96 97 98 //----------------------------------------------------------------------------- 99 // WorkerHost messages 100 // These are messages sent from the worker process to the renderer process. 101 // WorkerMsg_PostMessage is also sent here. 102 IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerContextClosed, 103 int /* worker_route_id */) 104 105 IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerContextDestroyed, 106 int /* worker_route_id */) 107 108 IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerScriptLoaded, 109 int /* worker_route_id */) 110 111 IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerScriptLoadFailed, 112 int /* worker_route_id */) 113 114 IPC_MESSAGE_CONTROL2(WorkerHostMsg_WorkerConnected, 115 int /* message_port_id */, 116 int /* worker_route_id */) 117