summaryrefslogtreecommitdiffstats
path: root/chrome/test/chromedriver/command_executor_impl.h
blob: 63904b38f9e1b4c4a945863da35766b0f9fea8ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_TEST_CHROMEDRIVER_COMMAND_EXECUTOR_IMPL_H_
#define CHROME_TEST_CHROMEDRIVER_COMMAND_EXECUTOR_IMPL_H_

#include <string>

#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread.h"
#include "chrome/test/chromedriver/command.h"
#include "chrome/test/chromedriver/command_executor.h"
#include "chrome/test/chromedriver/net/sync_websocket_factory.h"
#include "chrome/test/chromedriver/session_map.h"
#include "chrome/test/chromedriver/status.h"
#include "chrome/test/chromedriver/synchronized_map.h"

namespace base {
class DictionaryValue;
class Value;
}

class ChromeLauncherImpl;
class URLRequestContextGetter;

class CommandExecutorImpl : public CommandExecutor {
 public:
  CommandExecutorImpl();
  virtual ~CommandExecutorImpl();

  // Overridden from CommandExecutor:
  virtual void Init() OVERRIDE;
  virtual void ExecuteCommand(const std::string& name,
                              const base::DictionaryValue& params,
                              const std::string& session_id,
                              StatusCode* status_code,
                              scoped_ptr<base::Value>* value,
                              std::string* out_session_id) OVERRIDE;

 private:
  FRIEND_TEST_ALL_PREFIXES(CommandExecutorImplTest, SimpleCommand);
  FRIEND_TEST_ALL_PREFIXES(
      CommandExecutorImplTest, CommandThatDoesntSetValueOrSessionId);
  FRIEND_TEST_ALL_PREFIXES(CommandExecutorImplTest, CommandThatReturnsError);

  base::Thread io_thread_;
  scoped_refptr<URLRequestContextGetter> context_getter_;
  SyncWebSocketFactory socket_factory_;
  SessionMap session_map_;
  SynchronizedMap<std::string, Command> command_map_;

  DISALLOW_COPY_AND_ASSIGN(CommandExecutorImpl);
};

#endif  // CHROME_TEST_CHROMEDRIVER_COMMAND_EXECUTOR_IMPL_H_