Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / android / xwalk_dev_tools_server.h
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.
4
5 #ifndef XWALK_RUNTIME_BROWSER_ANDROID_XWALK_DEV_TOOLS_SERVER_H_
6 #define XWALK_RUNTIME_BROWSER_ANDROID_XWALK_DEV_TOOLS_SERVER_H_
7
8 #include <jni.h>
9 #include <string>
10 #include "base/basictypes.h"
11 #include "net/socket/unix_domain_server_socket_posix.h"
12
13 namespace content {
14 class DevToolsHttpHandler;
15 }
16
17 namespace xwalk {
18
19 // This class controls Developer Tools remote debugging server.
20 class XWalkDevToolsServer {
21  public:
22   explicit XWalkDevToolsServer(const std::string& socket_name);
23   ~XWalkDevToolsServer();
24
25   // Opens linux abstract socket to be ready for remote debugging.
26   void Start(bool allow_debug_permission);
27
28   // Closes debugging socket, stops debugging.
29   void Stop();
30
31   bool IsStarted() const;
32
33   void AllowConnectionFromUid(uid_t uid);
34
35  private:
36   bool CanUserConnectToDevTools(
37     const net::UnixDomainServerSocket::Credentials& credentials);
38
39   std::string socket_name_;
40   content::DevToolsHttpHandler* protocol_handler_;
41   uid_t allowed_uid_;
42
43   DISALLOW_COPY_AND_ASSIGN(XWalkDevToolsServer);
44 };
45
46 bool RegisterXWalkDevToolsServer(JNIEnv* env);
47
48 }  // namespace xwalk
49
50 #endif  // XWALK_RUNTIME_BROWSER_ANDROID_XWALK_DEV_TOOLS_SERVER_H_