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_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_
6 #define CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/test/chromedriver/chrome/browser_info.h"
14 #include "chrome/test/chromedriver/net/sync_websocket_factory.h"
24 class URLRequestContextGetter
;
38 WebViewInfo(const std::string
& id
,
39 const std::string
& debugger_url
,
40 const std::string
& url
,
44 bool IsFrontend() const;
47 std::string debugger_url
;
55 explicit WebViewsInfo(const std::vector
<WebViewInfo
>& info
);
58 const WebViewInfo
& Get(int index
) const;
59 size_t GetSize() const;
60 const WebViewInfo
* GetForId(const std::string
& id
) const;
63 std::vector
<WebViewInfo
> views_info
;
66 class DevToolsHttpClient
{
69 const NetAddress
& address
,
70 scoped_refptr
<URLRequestContextGetter
> context_getter
,
71 const SyncWebSocketFactory
& socket_factory
,
72 scoped_ptr
<DeviceMetrics
> device_metrics
);
73 ~DevToolsHttpClient();
75 Status
Init(const base::TimeDelta
& timeout
);
77 Status
GetWebViewsInfo(WebViewsInfo
* views_info
);
79 scoped_ptr
<DevToolsClient
> CreateClient(const std::string
& id
);
81 Status
CloseWebView(const std::string
& id
);
83 Status
ActivateWebView(const std::string
& id
);
85 const BrowserInfo
* browser_info();
86 const DeviceMetrics
* device_metrics();
89 Status
CloseFrontends(const std::string
& for_client_id
);
90 bool FetchUrlAndLog(const std::string
& url
,
91 URLRequestContextGetter
* getter
,
92 std::string
* response
);
94 scoped_refptr
<URLRequestContextGetter
> context_getter_
;
95 SyncWebSocketFactory socket_factory_
;
96 std::string server_url_
;
97 std::string web_socket_url_prefix_
;
98 BrowserInfo browser_info_
;
99 scoped_ptr
<DeviceMetrics
> device_metrics_
;
101 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpClient
);
105 Status
ParseWebViewsInfo(const std::string
& data
, WebViewsInfo
* views_info
);
106 Status
ParseType(const std::string
& data
, WebViewInfo::Type
* type
);
107 } // namespace internal
109 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_