OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Defines messages between the browser and worker process, as well as between | 5 // Defines messages between the browser and worker process, as well as between |
6 // the renderer and worker process. | 6 // the renderer and worker process. |
7 | 7 |
8 #ifndef CHROME_COMMON_WORKER_MESSAGES_H_ | 8 #ifndef CHROME_COMMON_WORKER_MESSAGES_H_ |
9 #define CHROME_COMMON_WORKER_MESSAGES_H_ | 9 #define CHROME_COMMON_WORKER_MESSAGES_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "chrome/common/common_param_traits.h" | 15 #include "chrome/common/common_param_traits.h" |
16 #include "ipc/ipc_message_utils.h" | 16 #include "ipc/ipc_message_utils.h" |
| 17 #include "googleurl/src/gurl.h" |
17 | 18 |
18 typedef std::pair<string16, std::vector<int> > QueuedMessage; | 19 typedef std::pair<string16, std::vector<int> > QueuedMessage; |
19 | 20 |
20 // Parameters structure for WorkerHostMsg_PostConsoleMessageToWorkerObject, | 21 // Parameters structure for WorkerHostMsg_PostConsoleMessageToWorkerObject, |
21 // which has too many data parameters to be reasonably put in a predefined | 22 // which has too many data parameters to be reasonably put in a predefined |
22 // IPC message. The data members directly correspond to parameters of | 23 // IPC message. The data members directly correspond to parameters of |
23 // WebWorkerClient::postConsoleMessageToWorkerObject() | 24 // WebWorkerClient::postConsoleMessageToWorkerObject() |
24 struct WorkerHostMsg_PostConsoleMessageToWorkerObject_Params { | 25 struct WorkerHostMsg_PostConsoleMessageToWorkerObject_Params { |
25 int source_identifier; | 26 int source_identifier; |
26 int message_type; | 27 int message_type; |
27 int message_level; | 28 int message_level; |
28 string16 message; | 29 string16 message; |
29 int line_number; | 30 int line_number; |
30 string16 source_url; | 31 string16 source_url; |
31 }; | 32 }; |
32 | 33 |
| 34 // Parameter structure for WorkerProcessMsg_CreateWorker. |
| 35 struct WorkerProcessMsg_CreateWorker_Params { |
| 36 GURL url; |
| 37 bool is_shared; |
| 38 string16 name; |
| 39 int route_id; |
| 40 int creator_process_id; |
| 41 int creator_appcache_host_id; // Only valid for dedicated workers. |
| 42 int64 shared_worker_appcache_id; // Only valid for shared workers. |
| 43 }; |
| 44 |
33 namespace IPC { | 45 namespace IPC { |
34 | 46 |
35 // Traits for WorkerHostMsg_PostConsoleMessageToWorkerObject_Params structure | 47 // Traits for WorkerHostMsg_PostConsoleMessageToWorkerObject_Params structure |
36 // to pack/unpack. | 48 // to pack/unpack. |
37 template <> | 49 template <> |
38 struct ParamTraits<WorkerHostMsg_PostConsoleMessageToWorkerObject_Params> { | 50 struct ParamTraits<WorkerHostMsg_PostConsoleMessageToWorkerObject_Params> { |
39 typedef WorkerHostMsg_PostConsoleMessageToWorkerObject_Params param_type; | 51 typedef WorkerHostMsg_PostConsoleMessageToWorkerObject_Params param_type; |
40 static void Write(Message* m, const param_type& p) { | 52 static void Write(Message* m, const param_type& p) { |
41 WriteParam(m, p.source_identifier); | 53 WriteParam(m, p.source_identifier); |
42 WriteParam(m, p.message_type); | 54 WriteParam(m, p.message_type); |
(...skipping 21 matching lines...) Expand all Loading... |
64 l->append(L", "); | 76 l->append(L", "); |
65 LogParam(p.message, l); | 77 LogParam(p.message, l); |
66 l->append(L", "); | 78 l->append(L", "); |
67 LogParam(p.line_number, l); | 79 LogParam(p.line_number, l); |
68 l->append(L", "); | 80 l->append(L", "); |
69 LogParam(p.source_url, l); | 81 LogParam(p.source_url, l); |
70 l->append(L")"); | 82 l->append(L")"); |
71 } | 83 } |
72 }; | 84 }; |
73 | 85 |
| 86 // Traits for WorkerProcessMsg_CreateWorker_Params. |
| 87 template <> |
| 88 struct ParamTraits<WorkerProcessMsg_CreateWorker_Params> { |
| 89 typedef WorkerProcessMsg_CreateWorker_Params param_type; |
| 90 static void Write(Message* m, const param_type& p) { |
| 91 WriteParam(m, p.url); |
| 92 WriteParam(m, p.is_shared); |
| 93 WriteParam(m, p.name); |
| 94 WriteParam(m, p.route_id); |
| 95 WriteParam(m, p.creator_process_id); |
| 96 WriteParam(m, p.creator_appcache_host_id); |
| 97 WriteParam(m, p.shared_worker_appcache_id); |
| 98 } |
| 99 static bool Read(const Message* m, void** iter, param_type* p) { |
| 100 return |
| 101 ReadParam(m, iter, &p->url) && |
| 102 ReadParam(m, iter, &p->is_shared) && |
| 103 ReadParam(m, iter, &p->name) && |
| 104 ReadParam(m, iter, &p->route_id) && |
| 105 ReadParam(m, iter, &p->creator_process_id) && |
| 106 ReadParam(m, iter, &p->creator_appcache_host_id) && |
| 107 ReadParam(m, iter, &p->shared_worker_appcache_id); |
| 108 } |
| 109 static void Log(const param_type& p, std::wstring* l) { |
| 110 l->append(L"("); |
| 111 LogParam(p.url, l); |
| 112 l->append(L", "); |
| 113 LogParam(p.is_shared, l); |
| 114 l->append(L", "); |
| 115 LogParam(p.name, l); |
| 116 l->append(L", "); |
| 117 LogParam(p.route_id, l); |
| 118 l->append(L", "); |
| 119 LogParam(p.creator_process_id, l); |
| 120 l->append(L", "); |
| 121 LogParam(p.creator_appcache_host_id, l); |
| 122 l->append(L", "); |
| 123 LogParam(p.shared_worker_appcache_id, l); |
| 124 l->append(L")"); |
| 125 } |
| 126 }; |
| 127 |
74 } // namespace IPC | 128 } // namespace IPC |
75 | 129 |
76 #define MESSAGES_INTERNAL_FILE "chrome/common/worker_messages_internal.h" | 130 #define MESSAGES_INTERNAL_FILE "chrome/common/worker_messages_internal.h" |
77 #include "ipc/ipc_message_macros.h" | 131 #include "ipc/ipc_message_macros.h" |
78 | 132 |
79 #endif // CHROME_COMMON_WORKER_MESSAGES_H_ | 133 #endif // CHROME_COMMON_WORKER_MESSAGES_H_ |
OLD | NEW |