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/net/sync_websocket_factory.h"
22 class URLRequestContextGetter;
33 WebViewInfo(const std::string& id,
34 const std::string& debugger_url,
35 const std::string& url,
39 bool IsFrontend() const;
42 std::string debugger_url;
50 explicit WebViewsInfo(const std::vector<WebViewInfo>& info);
53 const WebViewInfo& Get(int index) const;
54 size_t GetSize() const;
55 const WebViewInfo* GetForId(const std::string& id) const;
58 std::vector<WebViewInfo> views_info;
61 class DevToolsHttpClient {
64 const NetAddress& address,
65 scoped_refptr<URLRequestContextGetter> context_getter,
66 const SyncWebSocketFactory& socket_factory);
67 ~DevToolsHttpClient();
69 Status Init(const base::TimeDelta& timeout);
71 Status GetWebViewsInfo(WebViewsInfo* views_info);
73 scoped_ptr<DevToolsClient> CreateClient(const std::string& id);
75 Status CloseWebView(const std::string& id);
77 Status ActivateWebView(const std::string& id);
79 const std::string& version() const;
83 Status GetVersion(std::string* version);
84 Status CloseFrontends(const std::string& for_client_id);
85 bool FetchUrlAndLog(const std::string& url,
86 URLRequestContextGetter* getter,
87 std::string* response);
89 scoped_refptr<URLRequestContextGetter> context_getter_;
90 SyncWebSocketFactory socket_factory_;
91 std::string server_url_;
92 std::string web_socket_url_prefix_;
96 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpClient);
100 Status ParseWebViewsInfo(const std::string& data,
101 WebViewsInfo* views_info);
102 Status ParseVersionInfo(const std::string& data,
103 std::string* version);
104 } // namespace internal
106 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_HTTP_CLIENT_H_