OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/sync_socket.h" | 5 #include "base/sync_socket.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string> | 8 #include <string> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // messages from the client. | 51 // messages from the client. |
52 class SyncSocketServerListener : public IPC::Listener { | 52 class SyncSocketServerListener : public IPC::Listener { |
53 public: | 53 public: |
54 SyncSocketServerListener() : chan_(NULL) { | 54 SyncSocketServerListener() : chan_(NULL) { |
55 } | 55 } |
56 | 56 |
57 void Init(IPC::Channel* chan) { | 57 void Init(IPC::Channel* chan) { |
58 chan_ = chan; | 58 chan_ = chan; |
59 } | 59 } |
60 | 60 |
61 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { | 61 virtual bool OnMessageReceived(const IPC::Message& msg) override { |
62 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 62 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
63 IPC_BEGIN_MESSAGE_MAP(SyncSocketServerListener, msg) | 63 IPC_BEGIN_MESSAGE_MAP(SyncSocketServerListener, msg) |
64 IPC_MESSAGE_HANDLER(MsgClassSetHandle, OnMsgClassSetHandle) | 64 IPC_MESSAGE_HANDLER(MsgClassSetHandle, OnMsgClassSetHandle) |
65 IPC_MESSAGE_HANDLER(MsgClassShutdown, OnMsgClassShutdown) | 65 IPC_MESSAGE_HANDLER(MsgClassShutdown, OnMsgClassShutdown) |
66 IPC_END_MESSAGE_MAP() | 66 IPC_END_MESSAGE_MAP() |
67 } | 67 } |
68 return true; | 68 return true; |
69 } | 69 } |
70 | 70 |
71 private: | 71 private: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 class SyncSocketClientListener : public IPC::Listener { | 122 class SyncSocketClientListener : public IPC::Listener { |
123 public: | 123 public: |
124 SyncSocketClientListener() { | 124 SyncSocketClientListener() { |
125 } | 125 } |
126 | 126 |
127 void Init(base::SyncSocket* socket, IPC::Channel* chan) { | 127 void Init(base::SyncSocket* socket, IPC::Channel* chan) { |
128 socket_ = socket; | 128 socket_ = socket; |
129 chan_ = chan; | 129 chan_ = chan; |
130 } | 130 } |
131 | 131 |
132 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { | 132 virtual bool OnMessageReceived(const IPC::Message& msg) override { |
133 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 133 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
134 IPC_BEGIN_MESSAGE_MAP(SyncSocketClientListener, msg) | 134 IPC_BEGIN_MESSAGE_MAP(SyncSocketClientListener, msg) |
135 IPC_MESSAGE_HANDLER(MsgClassResponse, OnMsgClassResponse) | 135 IPC_MESSAGE_HANDLER(MsgClassResponse, OnMsgClassResponse) |
136 IPC_END_MESSAGE_MAP() | 136 IPC_END_MESSAGE_MAP() |
137 } | 137 } |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
141 private: | 141 private: |
142 // When a response is received from the server, it sends the same | 142 // When a response is received from the server, it sends the same |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 // Read from another socket to free some space for a new write. | 300 // Read from another socket to free some space for a new write. |
301 char hello[kHelloStringLength] = {0}; | 301 char hello[kHelloStringLength] = {0}; |
302 pair[1].Receive(&hello[0], sizeof(hello)); | 302 pair[1].Receive(&hello[0], sizeof(hello)); |
303 | 303 |
304 // Should be able to write more data to the buffer now. | 304 // Should be able to write more data to the buffer now. |
305 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength)); | 305 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength)); |
306 } | 306 } |
307 | 307 |
308 } // namespace | 308 } // namespace |
OLD | NEW |