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

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

Issue 11975003: [ChromeDriver] Add support for attaching multiple DevToolsEventListeners to a DevToolsClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added OVERRIDE. Created 7 years, 11 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 <string> 9 #include <string>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "chrome/test/chromedriver/devtools_client.h" 15 #include "chrome/test/chromedriver/devtools_client.h"
15 #include "chrome/test/chromedriver/net/sync_websocket_factory.h" 16 #include "chrome/test/chromedriver/net/sync_websocket_factory.h"
16 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
17 18
(...skipping 26 matching lines...) Expand all
44 } // namespace internal 45 } // namespace internal
45 46
46 class DevToolsEventListener; 47 class DevToolsEventListener;
47 class Status; 48 class Status;
48 class SyncWebSocket; 49 class SyncWebSocket;
49 50
50 class DevToolsClientImpl : public DevToolsClient { 51 class DevToolsClientImpl : public DevToolsClient {
51 public: 52 public:
52 // Listener may be NULL. 53 // Listener may be NULL.
53 DevToolsClientImpl(const SyncWebSocketFactory& factory, 54 DevToolsClientImpl(const SyncWebSocketFactory& factory,
54 const std::string& url, 55 const std::string& url);
55 DevToolsEventListener* listener);
56 56
57 typedef base::Callback<bool( 57 typedef base::Callback<bool(
58 const std::string&, 58 const std::string&,
59 int, 59 int,
60 internal::InspectorMessageType*, 60 internal::InspectorMessageType*,
61 internal::InspectorEvent*, 61 internal::InspectorEvent*,
62 internal::InspectorCommandResponse*)> ParserFunc; 62 internal::InspectorCommandResponse*)> ParserFunc;
63 DevToolsClientImpl(const SyncWebSocketFactory& factory, 63 DevToolsClientImpl(const SyncWebSocketFactory& factory,
64 const std::string& url, 64 const std::string& url,
65 DevToolsEventListener* listener,
66 const ParserFunc& parser_func); 65 const ParserFunc& parser_func);
67 66
68 virtual ~DevToolsClientImpl(); 67 virtual ~DevToolsClientImpl();
69 68
70 // Overridden from DevToolsClient: 69 // Overridden from DevToolsClient:
71 virtual Status SendCommand(const std::string& method, 70 virtual Status SendCommand(const std::string& method,
72 const base::DictionaryValue& params) OVERRIDE; 71 const base::DictionaryValue& params) OVERRIDE;
73 virtual Status SendCommandAndGetResult( 72 virtual Status SendCommandAndGetResult(
74 const std::string& method, 73 const std::string& method,
75 const base::DictionaryValue& params, 74 const base::DictionaryValue& params,
76 scoped_ptr<base::DictionaryValue>* result) OVERRIDE; 75 scoped_ptr<base::DictionaryValue>* result) OVERRIDE;
76 virtual void AddListener(DevToolsEventListener* listener) OVERRIDE;
77 77
78 private: 78 private:
79 Status SendCommandInternal( 79 Status SendCommandInternal(
80 const std::string& method, 80 const std::string& method,
81 const base::DictionaryValue& params, 81 const base::DictionaryValue& params,
82 scoped_ptr<base::DictionaryValue>* result); 82 scoped_ptr<base::DictionaryValue>* result);
83 virtual void NotifyEventListeners(const std::string& method,
84 const base::DictionaryValue& params);
83 scoped_ptr<SyncWebSocket> socket_; 85 scoped_ptr<SyncWebSocket> socket_;
84 GURL url_; 86 GURL url_;
85 DevToolsEventListener* listener_;
86 ParserFunc parser_func_; 87 ParserFunc parser_func_;
88 std::list<DevToolsEventListener*> listeners_;
87 bool connected_; 89 bool connected_;
88 int next_id_; 90 int next_id_;
89 91
90 DISALLOW_COPY_AND_ASSIGN(DevToolsClientImpl); 92 DISALLOW_COPY_AND_ASSIGN(DevToolsClientImpl);
91 }; 93 };
92 94
93 namespace internal { 95 namespace internal {
94 96
95 bool ParseInspectorMessage( 97 bool ParseInspectorMessage(
96 const std::string& message, 98 const std::string& message,
97 int expected_id, 99 int expected_id,
98 InspectorMessageType* type, 100 InspectorMessageType* type,
99 InspectorEvent* event, 101 InspectorEvent* event,
100 InspectorCommandResponse* command_response); 102 InspectorCommandResponse* command_response);
101 103
102 } // namespace internal 104 } // namespace internal
103 105
104 #endif // CHROME_TEST_CHROMEDRIVER_DEVTOOLS_CLIENT_IMPL_H_ 106 #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