Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / devtools / device / adb / mock_adb_server.h
blobd18c5a27b26adc2fb3f8a3029a39e3a5486882ad
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 enum FlushMode {
16 FlushWithoutSize,
17 FlushWithSize,
18 FlushWithData
21 void StartMockAdbServer(FlushMode flush_mode);
22 void StopMockAdbServer();
24 // Part of mock server independent of transport.
25 class MockAndroidConnection {
26 public:
27 class Delegate {
28 public:
29 virtual void SendSuccess(const std::string& message) {}
30 virtual void SendRaw(const std::string& data) {}
31 virtual void Close() {}
32 virtual ~Delegate() {}
34 using Callback = base::Callback<void(const std::string&)>;
35 MockAndroidConnection(Delegate* delegate,
36 const std::string& serial,
37 const std::string& command);
38 virtual ~MockAndroidConnection();
40 void Receive(const std::string& data);
42 private:
43 void ProcessCommand(const std::string& command);
44 void SendHTTPResponse(const std::string& body);
46 Delegate* delegate_;
47 std::string serial_;
48 std::string socket_name_;
49 std::string request_;
52 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_MOCK_ADB_SERVER_H_