Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / devtools / adb_web_socket.h
blob57a7fa860afb14004f3fa0cf0f83be02b7feaff5
1 // Copyright (c) 2013 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_ADB_WEB_SOCKET_H_
6 #define CHROME_BROWSER_DEVTOOLS_ADB_WEB_SOCKET_H_
8 #include "chrome/browser/devtools/android_device.h"
10 class AdbWebSocket : public base::RefCountedThreadSafe<AdbWebSocket> {
11 public:
12 class Delegate {
13 public:
14 virtual void OnSocketOpened() = 0;
15 virtual void OnFrameRead(const std::string& message) = 0;
16 virtual void OnSocketClosed(bool closed_by_device) = 0;
17 virtual bool ProcessIncomingMessage(const std::string& message) = 0;
19 protected:
20 virtual ~Delegate() {}
23 AdbWebSocket(scoped_refptr<AndroidDevice> device,
24 const std::string& socket_name,
25 const std::string& url,
26 base::MessageLoop* adb_message_loop,
27 Delegate* delegate);
29 void Disconnect();
31 void SendFrame(const std::string& message);
33 void SendFrameOnHandlerThread(const std::string& message);
35 private:
36 friend class base::RefCountedThreadSafe<AdbWebSocket>;
38 virtual ~AdbWebSocket();
40 void ConnectOnHandlerThread();
41 void ConnectedOnHandlerThread(int result, net::StreamSocket* socket);
42 void StartListeningOnHandlerThread();
43 void OnBytesRead(scoped_refptr<net::IOBuffer> response_buffer, int result);
44 void SendPendingRequests(int result);
45 void DisconnectOnHandlerThread(bool closed_by_device);
47 void OnSocketOpened();
48 void OnFrameRead(const std::string& message);
49 void OnSocketClosed(bool closed_by_device);
51 scoped_refptr<AndroidDevice> device_;
52 std::string socket_name_;
53 std::string url_;
54 base::MessageLoop* adb_message_loop_;
55 scoped_ptr<net::StreamSocket> socket_;
56 Delegate* delegate_;
57 std::string response_buffer_;
58 std::string request_buffer_;
59 DISALLOW_COPY_AND_ASSIGN(AdbWebSocket);
62 #endif // CHROME_BROWSER_DEVTOOLS_ADB_WEB_SOCKET_H_