| OLD | NEW |
| 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_CHROME_DEVTOOLS_CLIENT_IMPL_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_CLIENT_IMPL_H_ |
| 6 #define CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_CLIENT_IMPL_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_CHROME_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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 void SetParserFuncForTesting(const ParserFunc& parser_func); | 81 void SetParserFuncForTesting(const ParserFunc& parser_func); |
| 82 | 82 |
| 83 // Overridden from DevToolsClient: | 83 // Overridden from DevToolsClient: |
| 84 const std::string& GetId() override; | 84 const std::string& GetId() override; |
| 85 bool WasCrashed() override; | 85 bool WasCrashed() override; |
| 86 Status ConnectIfNecessary() override; | 86 Status ConnectIfNecessary() override; |
| 87 Status SendCommand( | 87 Status SendCommand( |
| 88 const std::string& method, | 88 const std::string& method, |
| 89 const base::DictionaryValue& params) override; | 89 const base::DictionaryValue& params) override; |
| 90 Status SendCommandWithTimeout( |
| 91 const std::string& method, |
| 92 const base::DictionaryValue& params, |
| 93 const Timeout* timeout) override; |
| 90 Status SendAsyncCommand( | 94 Status SendAsyncCommand( |
| 91 const std::string& method, | 95 const std::string& method, |
| 92 const base::DictionaryValue& params) override; | 96 const base::DictionaryValue& params) override; |
| 93 Status SendCommandAndGetResult( | 97 Status SendCommandAndGetResult( |
| 94 const std::string& method, | 98 const std::string& method, |
| 95 const base::DictionaryValue& params, | 99 const base::DictionaryValue& params, |
| 96 scoped_ptr<base::DictionaryValue>* result) override; | 100 scoped_ptr<base::DictionaryValue>* result) override; |
| 101 Status SendCommandAndGetResultWithTimeout( |
| 102 const std::string& method, |
| 103 const base::DictionaryValue& params, |
| 104 const Timeout* timeout, |
| 105 scoped_ptr<base::DictionaryValue>* result) override; |
| 97 void AddListener(DevToolsEventListener* listener) override; | 106 void AddListener(DevToolsEventListener* listener) override; |
| 98 Status HandleEventsUntil(const ConditionalFunc& conditional_func, | 107 Status HandleEventsUntil(const ConditionalFunc& conditional_func, |
| 99 const base::TimeDelta& timeout) override; | 108 const Timeout& timeout) override; |
| 100 Status HandleReceivedEvents() override; | 109 Status HandleReceivedEvents() override; |
| 101 | 110 |
| 102 private: | 111 private: |
| 103 enum ResponseState { | 112 enum ResponseState { |
| 104 // The client is waiting for the response. | 113 // The client is waiting for the response. |
| 105 kWaiting, | 114 kWaiting, |
| 106 // The command response will not be received because it is blocked by an | 115 // The command response will not be received because it is blocked by an |
| 107 // alert that the command triggered. | 116 // alert that the command triggered. |
| 108 kBlocked, | 117 kBlocked, |
| 109 // The client no longer cares about the response. | 118 // The client no longer cares about the response. |
| 110 kIgnored, | 119 kIgnored, |
| 111 // The response has been received. | 120 // The response has been received. |
| 112 kReceived | 121 kReceived |
| 113 }; | 122 }; |
| 114 struct ResponseInfo { | 123 struct ResponseInfo { |
| 115 explicit ResponseInfo(const std::string& method); | 124 explicit ResponseInfo(const std::string& method); |
| 116 ~ResponseInfo(); | 125 ~ResponseInfo(); |
| 117 | 126 |
| 118 ResponseState state; | 127 ResponseState state; |
| 119 std::string method; | 128 std::string method; |
| 120 internal::InspectorCommandResponse response; | 129 internal::InspectorCommandResponse response; |
| 121 }; | 130 }; |
| 122 typedef std::map<int, linked_ptr<ResponseInfo> > ResponseInfoMap; | 131 typedef std::map<int, linked_ptr<ResponseInfo> > ResponseInfoMap; |
| 123 | 132 |
| 124 Status SendCommandInternal( | 133 Status SendCommandInternal( |
| 125 const std::string& method, | 134 const std::string& method, |
| 126 const base::DictionaryValue& params, | 135 const base::DictionaryValue& params, |
| 127 scoped_ptr<base::DictionaryValue>* result, | 136 scoped_ptr<base::DictionaryValue>* result, |
| 128 bool wait_for_response); | 137 bool wait_for_response, |
| 129 Status ProcessNextMessage(int expected_id, const base::TimeDelta& timeout); | 138 const Timeout* timeout); |
| 139 Status ProcessNextMessage(int expected_id, const Timeout& timeout); |
| 130 Status ProcessEvent(const internal::InspectorEvent& event); | 140 Status ProcessEvent(const internal::InspectorEvent& event); |
| 131 Status ProcessCommandResponse( | 141 Status ProcessCommandResponse( |
| 132 const internal::InspectorCommandResponse& response); | 142 const internal::InspectorCommandResponse& response); |
| 133 Status EnsureListenersNotifiedOfConnect(); | 143 Status EnsureListenersNotifiedOfConnect(); |
| 134 Status EnsureListenersNotifiedOfEvent(); | 144 Status EnsureListenersNotifiedOfEvent(); |
| 135 Status EnsureListenersNotifiedOfCommandResponse(); | 145 Status EnsureListenersNotifiedOfCommandResponse(); |
| 136 | 146 |
| 137 scoped_ptr<SyncWebSocket> socket_; | 147 scoped_ptr<SyncWebSocket> socket_; |
| 138 GURL url_; | 148 GURL url_; |
| 139 bool crashed_; | 149 bool crashed_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 158 bool ParseInspectorMessage( | 168 bool ParseInspectorMessage( |
| 159 const std::string& message, | 169 const std::string& message, |
| 160 int expected_id, | 170 int expected_id, |
| 161 InspectorMessageType* type, | 171 InspectorMessageType* type, |
| 162 InspectorEvent* event, | 172 InspectorEvent* event, |
| 163 InspectorCommandResponse* command_response); | 173 InspectorCommandResponse* command_response); |
| 164 | 174 |
| 165 } // namespace internal | 175 } // namespace internal |
| 166 | 176 |
| 167 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_CLIENT_IMPL_H_ | 177 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_CLIENT_IMPL_H_ |
| OLD | NEW |