• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_ADB_DEVICE_INFO_QUERY_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_ADB_DEVICE_INFO_QUERY_H_
7 
8 #include "base/threading/non_thread_safe.h"
9 #include "chrome/browser/devtools/device/android_device_manager.h"
10 
11 class AdbDeviceInfoQuery : public base::NonThreadSafe {
12  public:
13   static AndroidDeviceManager::BrowserInfo::Type GetBrowserType(
14       const std::string& socket);
15 
16   static std::string GetDisplayName(const std::string& socket,
17                                     const std::string& package);
18 
19   typedef AndroidDeviceManager::CommandCallback CommandCallback;
20   typedef AndroidDeviceManager::DeviceInfoCallback DeviceInfoCallback;
21 
22   typedef base::Callback<
23       void(const std::string&, const CommandCallback&)> RunCommandCallback;
24 
25   static void Start(const RunCommandCallback& command_callback,
26                     const DeviceInfoCallback& callback);
27 
28  private:
29   AdbDeviceInfoQuery(const RunCommandCallback& command_callback,
30                      const DeviceInfoCallback& callback);
31 
32   virtual ~AdbDeviceInfoQuery();
33 
34   void ReceivedModel(int result, const std::string& response);
35 
36   void ReceivedDumpsys(int result, const std::string& response);
37 
38   void ParseDumpsysResponse(const std::string& response);
39 
40   void ParseScreenSize(const std::string& str);
41 
42   void ReceivedProcesses(int result,
43                          const std::string& processes_response);
44 
45   void ReceivedSockets(const std::string& processes_response,
46                        int result,
47                        const std::string& sockets_response);
48 
49   void ParseBrowserInfo(const std::string& processes_response,
50                         const std::string& sockets_response);
51 
52   void Respond();
53 
54   RunCommandCallback command_callback_;
55   DeviceInfoCallback callback_;
56   AndroidDeviceManager::DeviceInfo device_info_;
57 
58   DISALLOW_COPY_AND_ASSIGN(AdbDeviceInfoQuery);
59 };
60 
61 #endif  // CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_ADB_DEVICE_INFO_QUERY_H_
62