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.
5 #ifndef CHROME_TEST_CHROMEDRIVER_NET_SYNC_WEBSOCKET_H_
6 #define CHROME_TEST_CHROMEDRIVER_NET_SYNC_WEBSOCKET_H_
10 #include "base/time/time.h"
14 // Proxy for using a WebSocket running on a background thread synchronously.
23 virtual ~SyncWebSocket() {}
25 // Return true if connected, otherwise return false.
26 virtual bool IsConnected() = 0;
28 // Connects to the WebSocket server. Returns true on success.
29 virtual bool Connect(const GURL
& url
) = 0;
31 // Sends message. Returns true on success.
32 virtual bool Send(const std::string
& message
) = 0;
34 // Receives next message and modifies the message on success. Returns
35 // StatusCode::kTimedout if no message is received within |timeout|.
36 // Returns StatusCode::kDisconnected if the socket is closed.
37 virtual StatusCode
ReceiveNextMessage(
39 const base::TimeDelta
& timeout
) = 0;
41 // Returns whether there are any messages that have been received and not yet
42 // handled by ReceiveNextMessage.
43 virtual bool HasNextMessage() = 0;
46 #endif // CHROME_TEST_CHROMEDRIVER_NET_SYNC_WEBSOCKET_H_