| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_ |
| 6 #define CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/test/chromedriver/chrome/version.h" | 13 #include "chrome/test/chromedriver/chrome/version.h" |
| 14 #include "chrome/test/chromedriver/net/sync_websocket_factory.h" | 14 #include "chrome/test/chromedriver/net/sync_websocket_factory.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class TimeDelta; | 17 class TimeDelta; |
| 18 } | 18 } |
| 19 | 19 |
| 20 struct DeviceMetrics; |
| 20 class DevToolsClient; | 21 class DevToolsClient; |
| 21 class NetAddress; | 22 class NetAddress; |
| 22 class Status; | 23 class Status; |
| 23 class URLRequestContextGetter; | 24 class URLRequestContextGetter; |
| 24 | 25 |
| 25 struct WebViewInfo { | 26 struct WebViewInfo { |
| 26 enum Type { | 27 enum Type { |
| 27 kApp, | 28 kApp, |
| 28 kBackgroundPage, | 29 kBackgroundPage, |
| 29 kPage, | 30 kPage, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 std::vector<WebViewInfo> views_info; | 60 std::vector<WebViewInfo> views_info; |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 class DevToolsHttpClient { | 63 class DevToolsHttpClient { |
| 63 public: | 64 public: |
| 64 DevToolsHttpClient( | 65 DevToolsHttpClient( |
| 65 const NetAddress& address, | 66 const NetAddress& address, |
| 66 scoped_refptr<URLRequestContextGetter> context_getter, | 67 scoped_refptr<URLRequestContextGetter> context_getter, |
| 67 const SyncWebSocketFactory& socket_factory); | 68 const SyncWebSocketFactory& socket_factory, |
| 69 scoped_ptr<DeviceMetrics> device_metrics); |
| 68 ~DevToolsHttpClient(); | 70 ~DevToolsHttpClient(); |
| 69 | 71 |
| 70 Status Init(const base::TimeDelta& timeout); | 72 Status Init(const base::TimeDelta& timeout); |
| 71 | 73 |
| 72 Status GetWebViewsInfo(WebViewsInfo* views_info); | 74 Status GetWebViewsInfo(WebViewsInfo* views_info); |
| 73 | 75 |
| 74 scoped_ptr<DevToolsClient> CreateClient(const std::string& id); | 76 scoped_ptr<DevToolsClient> CreateClient(const std::string& id); |
| 75 | 77 |
| 76 Status CloseWebView(const std::string& id); | 78 Status CloseWebView(const std::string& id); |
| 77 | 79 |
| 78 Status ActivateWebView(const std::string& id); | 80 Status ActivateWebView(const std::string& id); |
| 79 | 81 |
| 80 const BrowserInfo* browser_info(); | 82 const BrowserInfo* browser_info(); |
| 83 const DeviceMetrics* device_metrics(); |
| 81 | 84 |
| 82 private: | 85 private: |
| 83 Status GetVersion(std::string* browser_version, std::string* blink_version); | 86 Status GetVersion(std::string* browser_version, std::string* blink_version); |
| 84 Status CloseFrontends(const std::string& for_client_id); | 87 Status CloseFrontends(const std::string& for_client_id); |
| 85 bool FetchUrlAndLog(const std::string& url, | 88 bool FetchUrlAndLog(const std::string& url, |
| 86 URLRequestContextGetter* getter, | 89 URLRequestContextGetter* getter, |
| 87 std::string* response); | 90 std::string* response); |
| 88 | 91 |
| 89 scoped_refptr<URLRequestContextGetter> context_getter_; | 92 scoped_refptr<URLRequestContextGetter> context_getter_; |
| 90 SyncWebSocketFactory socket_factory_; | 93 SyncWebSocketFactory socket_factory_; |
| 91 std::string server_url_; | 94 std::string server_url_; |
| 92 std::string web_socket_url_prefix_; | 95 std::string web_socket_url_prefix_; |
| 93 BrowserInfo browser_info_; | 96 BrowserInfo browser_info_; |
| 97 scoped_ptr<DeviceMetrics> device_metrics_; |
| 94 | 98 |
| 95 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpClient); | 99 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpClient); |
| 96 }; | 100 }; |
| 97 | 101 |
| 98 namespace internal { | 102 namespace internal { |
| 99 Status ParseWebViewsInfo(const std::string& data, | 103 Status ParseWebViewsInfo(const std::string& data, |
| 100 WebViewsInfo* views_info); | 104 WebViewsInfo* views_info); |
| 101 Status ParseVersionInfo(const std::string& data, | 105 Status ParseVersionInfo(const std::string& data, |
| 102 std::string* browser_version, | 106 std::string* browser_version, |
| 103 std::string* blink_version); | 107 std::string* blink_version); |
| 104 } // namespace internal | 108 } // namespace internal |
| 105 | 109 |
| 106 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_ | 110 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_ |
| OLD | NEW |