| 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 #ifndef CHROME_TEST_CHROMEDRIVER_NET_SYNC_WEBSOCKET_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_NET_SYNC_WEBSOCKET_H_ |
| 6 #define CHROME_TEST_CHROMEDRIVER_NET_SYNC_WEBSOCKET_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_NET_SYNC_WEBSOCKET_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 class GURL; | 10 class GURL; |
| 11 | 11 |
| 12 // Proxy for using a WebSocket running on a background thread synchronously. | 12 // Proxy for using a WebSocket running on a background thread synchronously. |
| 13 class SyncWebSocket { | 13 class SyncWebSocket { |
| 14 public: | 14 public: |
| 15 virtual ~SyncWebSocket() {} | 15 virtual ~SyncWebSocket() {} |
| 16 | 16 |
| 17 // Return true if connected, otherwise return false. |
| 18 virtual bool IsConnected() = 0; |
| 19 |
| 17 // Connects to the WebSocket server. Returns true on success. | 20 // Connects to the WebSocket server. Returns true on success. |
| 18 virtual bool Connect(const GURL& url) = 0; | 21 virtual bool Connect(const GURL& url) = 0; |
| 19 | 22 |
| 20 // Sends message. Returns true on success. | 23 // Sends message. Returns true on success. |
| 21 virtual bool Send(const std::string& message) = 0; | 24 virtual bool Send(const std::string& message) = 0; |
| 22 | 25 |
| 23 // Receives next message. Blocks until at least one message is received or | 26 // Receives next message. Blocks until at least one message is received or |
| 24 // the socket is closed. Returns true on success and modifies |message|. | 27 // the socket is closed. Returns true on success and modifies |message|. |
| 25 virtual bool ReceiveNextMessage(std::string* message) = 0; | 28 virtual bool ReceiveNextMessage(std::string* message) = 0; |
| 26 | 29 |
| 27 // Returns whether there are any messages that have been received and not yet | 30 // Returns whether there are any messages that have been received and not yet |
| 28 // handled by ReceiveNextMessage. | 31 // handled by ReceiveNextMessage. |
| 29 virtual bool HasNextMessage() = 0; | 32 virtual bool HasNextMessage() = 0; |
| 30 }; | 33 }; |
| 31 | 34 |
| 32 #endif // CHROME_TEST_CHROMEDRIVER_NET_SYNC_WEBSOCKET_H_ | 35 #endif // CHROME_TEST_CHROMEDRIVER_NET_SYNC_WEBSOCKET_H_ |
| OLD | NEW |