DevTools: cut host and port from webSocketDebuggerUrl in addition to ws:// prefix
[chromium-blink-merge.git] / chrome / browser / devtools / device / adb / mock_adb_server.h
blob3f3e32ff7130a68db4ed721af6cef27017c1c91e
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_MOCK_ADB_SERVER_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_MOCK_ADB_SERVER_H_
8 #include <string>
10 #include "base/callback.h"
12 // Single instance mock ADB server for use in browser tests. Runs on IO thread.
14 // These methods can be called from any thread.
15 void StartMockAdbServer();
16 void StopMockAdbServer();
18 // Part of mock server independent of transport.
19 class MockAndroidConnection {
20 public:
21 class Delegate {
22 public:
23 virtual void SendSuccess(const std::string& message) {}
24 virtual void SendRaw(const std::string& data) {}
25 virtual void Close() {}
26 virtual ~Delegate() {}
28 using Callback = base::Callback<void(const std::string&)>;
29 MockAndroidConnection(Delegate* delegate,
30 const std::string& serial,
31 const std::string& command);
32 virtual ~MockAndroidConnection();
34 void Receive(const std::string& data);
36 private:
37 void ProcessCommand(const std::string& command);
38 void SendHTTPResponse(const std::string& body);
40 Delegate* delegate_;
41 std::string serial_;
42 std::string socket_name_;
43 std::string request_;
46 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_MOCK_ADB_SERVER_H_