- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / chromedriver / chrome / devtools_client.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_CLIENT_H_
6 #define CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_CLIENT_H_
7
8 #include <string>
9
10 #include "base/callback_forward.h"
11 #include "base/memory/scoped_ptr.h"
12
13 namespace base {
14 class DictionaryValue;
15 class TimeDelta;
16 }
17
18 class DevToolsEventListener;
19 class Status;
20
21 // A DevTools client of a single DevTools debugger.
22 class DevToolsClient {
23  public:
24   typedef base::Callback<Status(bool* is_condition_met)> ConditionalFunc;
25
26   virtual ~DevToolsClient() {}
27
28   virtual const std::string& GetId() = 0;
29
30   virtual bool WasCrashed() = 0;
31
32   // Connect to DevTools if the DevToolsClient is disconnected.
33   virtual Status ConnectIfNecessary() = 0;
34
35   virtual Status SendCommand(const std::string& method,
36                              const base::DictionaryValue& params) = 0;
37   virtual Status SendCommandAndGetResult(
38       const std::string& method,
39       const base::DictionaryValue& params,
40       scoped_ptr<base::DictionaryValue>* result) = 0;
41
42   // Adds a listener. This must only be done when the client is disconnected.
43   virtual void AddListener(DevToolsEventListener* listener) = 0;
44
45   // Handles events until the given function reports the condition is met
46   // and there are no more received events to handle. If the given
47   // function ever returns an error, returns immediately with the error.
48   // If the condition is not met within |timeout|, kTimeout status
49   // is returned eventually. If |timeout| is 0, this function will not block.
50   virtual Status HandleEventsUntil(const ConditionalFunc& conditional_func,
51                                    const base::TimeDelta& timeout) = 0;
52
53   // Handles events that have been received but not yet handled.
54   virtual Status HandleReceivedEvents() = 0;
55 };
56
57 #endif  // CHROME_TEST_CHROMEDRIVER_CHROME_DEVTOOLS_CLIENT_H_