Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: chrome/test/chromedriver/devtools_client_impl.h

Issue 12321057: [chromedriver] Implement reconnection to DevTools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_DEVTOOLS_CLIENT_IMPL_H_ 5 #ifndef CHROME_TEST_CHROMEDRIVER_DEVTOOLS_CLIENT_IMPL_H_
6 #define CHROME_TEST_CHROMEDRIVER_DEVTOOLS_CLIENT_IMPL_H_ 6 #define CHROME_TEST_CHROMEDRIVER_DEVTOOLS_CLIENT_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 }; 44 };
45 45
46 } // namespace internal 46 } // namespace internal
47 47
48 class DevToolsEventListener; 48 class DevToolsEventListener;
49 class Status; 49 class Status;
50 class SyncWebSocket; 50 class SyncWebSocket;
51 51
52 class DevToolsClientImpl : public DevToolsClient { 52 class DevToolsClientImpl : public DevToolsClient {
53 public: 53 public:
54 typedef base::Callback<Status()> FrontendCloserFunc;
54 DevToolsClientImpl(const SyncWebSocketFactory& factory, 55 DevToolsClientImpl(const SyncWebSocketFactory& factory,
55 const std::string& url); 56 const std::string& url,
57 const FrontendCloserFunc& frontend_closer_func);
56 58
57 typedef base::Callback<bool( 59 typedef base::Callback<bool(
58 const std::string&, 60 const std::string&,
59 int, 61 int,
60 internal::InspectorMessageType*, 62 internal::InspectorMessageType*,
61 internal::InspectorEvent*, 63 internal::InspectorEvent*,
62 internal::InspectorCommandResponse*)> ParserFunc; 64 internal::InspectorCommandResponse*)> ParserFunc;
63 DevToolsClientImpl(const SyncWebSocketFactory& factory, 65 DevToolsClientImpl(const SyncWebSocketFactory& factory,
64 const std::string& url, 66 const std::string& url,
67 const FrontendCloserFunc& frontend_closer_func,
65 const ParserFunc& parser_func); 68 const ParserFunc& parser_func);
66 69
67 virtual ~DevToolsClientImpl(); 70 virtual ~DevToolsClientImpl();
68 71
69 void SetParserFuncForTesting(const ParserFunc& parser_func); 72 void SetParserFuncForTesting(const ParserFunc& parser_func);
70 73
71 // Overridden from DevToolsClient: 74 // Overridden from DevToolsClient:
75 virtual Status ConnectIfNecessary() OVERRIDE;
72 virtual Status SendCommand(const std::string& method, 76 virtual Status SendCommand(const std::string& method,
73 const base::DictionaryValue& params) OVERRIDE; 77 const base::DictionaryValue& params) OVERRIDE;
74 virtual Status SendCommandAndGetResult( 78 virtual Status SendCommandAndGetResult(
75 const std::string& method, 79 const std::string& method,
76 const base::DictionaryValue& params, 80 const base::DictionaryValue& params,
77 scoped_ptr<base::DictionaryValue>* result) OVERRIDE; 81 scoped_ptr<base::DictionaryValue>* result) OVERRIDE;
78 virtual void AddListener(DevToolsEventListener* listener) OVERRIDE; 82 virtual void AddListener(DevToolsEventListener* listener) OVERRIDE;
79 virtual Status HandleEventsUntil( 83 virtual Status HandleEventsUntil(
80 const ConditionalFunc& conditional_func) OVERRIDE; 84 const ConditionalFunc& conditional_func) OVERRIDE;
81 85
82 private: 86 private:
83 Status SendCommandInternal( 87 Status SendCommandInternal(
84 const std::string& method, 88 const std::string& method,
85 const base::DictionaryValue& params, 89 const base::DictionaryValue& params,
86 scoped_ptr<base::DictionaryValue>* result); 90 scoped_ptr<base::DictionaryValue>* result);
87 Status ReceiveCommandResponse( 91 Status ReceiveCommandResponse(
88 int command_id, 92 int command_id,
89 scoped_ptr<base::DictionaryValue>* result); 93 scoped_ptr<base::DictionaryValue>* result);
90 Status ReceiveNextMessage( 94 Status ReceiveNextMessage(
91 int expected_id, 95 int expected_id,
92 internal::InspectorMessageType* type, 96 internal::InspectorMessageType* type,
93 internal::InspectorEvent* event, 97 internal::InspectorEvent* event,
94 internal::InspectorCommandResponse* response); 98 internal::InspectorCommandResponse* response);
95 bool HasReceivedCommandResponse(int cmd_id); 99 bool HasReceivedCommandResponse(int cmd_id);
96 Status NotifyEventListeners(const std::string& method, 100 Status NotifyEventListeners(const std::string& method,
97 const base::DictionaryValue& params); 101 const base::DictionaryValue& params);
98 scoped_ptr<SyncWebSocket> socket_; 102 scoped_ptr<SyncWebSocket> socket_;
99 GURL url_; 103 GURL url_;
104 FrontendCloserFunc frontend_closer_func_;
100 ParserFunc parser_func_; 105 ParserFunc parser_func_;
101 std::list<DevToolsEventListener*> listeners_; 106 std::list<DevToolsEventListener*> listeners_;
102 std::list<DevToolsEventListener*> listeners_for_on_connected_; 107 std::list<DevToolsEventListener*> listeners_for_on_connected_;
103 typedef std::map<int, base::DictionaryValue*> ResponseMap; 108 typedef std::map<int, base::DictionaryValue*> ResponseMap;
104 ResponseMap cmd_response_map_; 109 ResponseMap cmd_response_map_;
105 bool connected_;
106 int next_id_; 110 int next_id_;
107 111
108 DISALLOW_COPY_AND_ASSIGN(DevToolsClientImpl); 112 DISALLOW_COPY_AND_ASSIGN(DevToolsClientImpl);
109 }; 113 };
110 114
111 namespace internal { 115 namespace internal {
112 116
113 bool ParseInspectorMessage( 117 bool ParseInspectorMessage(
114 const std::string& message, 118 const std::string& message,
115 int expected_id, 119 int expected_id,
116 InspectorMessageType* type, 120 InspectorMessageType* type,
117 InspectorEvent* event, 121 InspectorEvent* event,
118 InspectorCommandResponse* command_response); 122 InspectorCommandResponse* command_response);
119 123
120 } // namespace internal 124 } // namespace internal
121 125
122 #endif // CHROME_TEST_CHROMEDRIVER_DEVTOOLS_CLIENT_IMPL_H_ 126 #endif // CHROME_TEST_CHROMEDRIVER_DEVTOOLS_CLIENT_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/devtools_client.h ('k') | chrome/test/chromedriver/devtools_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698