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 #include "content/child/shared_worker_devtools_agent.h" | 5 #include "content/child/shared_worker_devtools_agent.h" |
6 | 6 |
7 #include "content/child/child_thread_impl.h" | 7 #include "content/child/child_thread_impl.h" |
8 #include "content/common/devtools_messages.h" | 8 #include "content/common/devtools_messages.h" |
9 #include "ipc/ipc_channel.h" | 9 #include "ipc/ipc_channel.h" |
10 #include "third_party/WebKit/public/platform/WebCString.h" | 10 #include "third_party/WebKit/public/platform/WebCString.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) | 37 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) |
38 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) | 38 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) |
39 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, | 39 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, |
40 OnDispatchOnInspectorBackend) | 40 OnDispatchOnInspectorBackend) |
41 IPC_MESSAGE_UNHANDLED(handled = false) | 41 IPC_MESSAGE_UNHANDLED(handled = false) |
42 IPC_END_MESSAGE_MAP() | 42 IPC_END_MESSAGE_MAP() |
43 return handled; | 43 return handled; |
44 } | 44 } |
45 | 45 |
46 void SharedWorkerDevToolsAgent::SendDevToolsMessage( | 46 void SharedWorkerDevToolsAgent::SendDevToolsMessage( |
| 47 int session_id, |
47 int call_id, | 48 int call_id, |
48 const blink::WebString& msg, | 49 const blink::WebString& msg, |
49 const blink::WebString& state) { | 50 const blink::WebString& state) { |
50 std::string message = msg.utf8(); | 51 std::string message = msg.utf8(); |
51 std::string post_state = state.utf8(); | 52 std::string post_state = state.utf8(); |
52 DevToolsMessageChunk chunk; | 53 DevToolsMessageChunk chunk; |
53 chunk.message_size = message.size(); | 54 chunk.message_size = message.size(); |
54 chunk.is_first = true; | 55 chunk.is_first = true; |
55 | 56 |
56 if (message.length() < kMaxMessageChunkSize) { | 57 if (message.length() < kMaxMessageChunkSize) { |
57 chunk.data.swap(message); | 58 chunk.data.swap(message); |
| 59 chunk.session_id = session_id; |
58 chunk.call_id = call_id; | 60 chunk.call_id = call_id; |
59 chunk.post_state = post_state; | 61 chunk.post_state = post_state; |
60 chunk.is_last = true; | 62 chunk.is_last = true; |
61 Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( | 63 Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( |
62 route_id_, chunk)); | 64 route_id_, chunk)); |
63 return; | 65 return; |
64 } | 66 } |
65 | 67 |
66 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { | 68 for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { |
67 chunk.is_last = pos + kMaxMessageChunkSize >= message.length(); | 69 chunk.is_last = pos + kMaxMessageChunkSize >= message.length(); |
| 70 chunk.session_id = chunk.is_last ? session_id : 0; |
68 chunk.call_id = chunk.is_last ? call_id : 0; | 71 chunk.call_id = chunk.is_last ? call_id : 0; |
69 chunk.post_state = chunk.is_last ? post_state : std::string(); | 72 chunk.post_state = chunk.is_last ? post_state : std::string(); |
70 chunk.data = message.substr(pos, kMaxMessageChunkSize); | 73 chunk.data = message.substr(pos, kMaxMessageChunkSize); |
71 Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( | 74 Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( |
72 route_id_, chunk)); | 75 route_id_, chunk)); |
73 chunk.is_first = false; | 76 chunk.is_first = false; |
74 chunk.message_size = 0; | 77 chunk.message_size = 0; |
75 } | 78 } |
76 } | 79 } |
77 | 80 |
78 void SharedWorkerDevToolsAgent::OnAttach(const std::string& host_id) { | 81 void SharedWorkerDevToolsAgent::OnAttach(const std::string& host_id, |
79 webworker_->attachDevTools(WebString::fromUTF8(host_id)); | 82 int session_id) { |
| 83 webworker_->attachDevTools(WebString::fromUTF8(host_id), session_id); |
80 } | 84 } |
81 | 85 |
82 void SharedWorkerDevToolsAgent::OnReattach(const std::string& host_id, | 86 void SharedWorkerDevToolsAgent::OnReattach(const std::string& host_id, |
| 87 int session_id, |
83 const std::string& state) { | 88 const std::string& state) { |
84 webworker_->reattachDevTools(WebString::fromUTF8(host_id), | 89 webworker_->reattachDevTools(WebString::fromUTF8(host_id), session_id, |
85 WebString::fromUTF8(state)); | 90 WebString::fromUTF8(state)); |
86 } | 91 } |
87 | 92 |
88 void SharedWorkerDevToolsAgent::OnDetach() { | 93 void SharedWorkerDevToolsAgent::OnDetach() { |
89 webworker_->detachDevTools(); | 94 webworker_->detachDevTools(); |
90 } | 95 } |
91 | 96 |
92 void SharedWorkerDevToolsAgent::OnDispatchOnInspectorBackend( | 97 void SharedWorkerDevToolsAgent::OnDispatchOnInspectorBackend( |
| 98 int session_id, |
93 const std::string& message) { | 99 const std::string& message) { |
94 webworker_->dispatchDevToolsMessage(WebString::fromUTF8(message)); | 100 webworker_->dispatchDevToolsMessage(session_id, WebString::fromUTF8(message)); |
95 } | 101 } |
96 | 102 |
97 bool SharedWorkerDevToolsAgent::Send(IPC::Message* message) { | 103 bool SharedWorkerDevToolsAgent::Send(IPC::Message* message) { |
98 return ChildThreadImpl::current()->Send(message); | 104 return ChildThreadImpl::current()->Send(message); |
99 } | 105 } |
100 | 106 |
101 } // namespace content | 107 } // namespace content |
OLD | NEW |