Home | History | Annotate | Download | only in chromedriver
      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_COMMANDS_H_
      6 #define CHROME_TEST_CHROMEDRIVER_COMMANDS_H_
      7 
      8 #include <string>
      9 
     10 #include "base/callback_forward.h"
     11 #include "base/memory/ref_counted.h"
     12 #include "base/memory/scoped_ptr.h"
     13 #include "chrome/test/chromedriver/command.h"
     14 #include "chrome/test/chromedriver/net/sync_websocket_factory.h"
     15 #include "chrome/test/chromedriver/session_thread_map.h"
     16 
     17 namespace base {
     18 class DictionaryValue;
     19 class Value;
     20 }
     21 
     22 class DeviceManager;
     23 class Log;
     24 struct Session;
     25 class Status;
     26 class URLRequestContextGetter;
     27 
     28 // Gets status/info about ChromeDriver.
     29 void ExecuteGetStatus(
     30     const base::DictionaryValue& params,
     31     const std::string& session_id,
     32     const CommandCallback& callback);
     33 
     34 struct NewSessionParams {
     35   NewSessionParams(Log* log,
     36                    SessionThreadMap* session_thread_map,
     37                    scoped_refptr<URLRequestContextGetter> context_getter,
     38                    const SyncWebSocketFactory& socket_factory,
     39                    DeviceManager* device_manager);
     40   ~NewSessionParams();
     41 
     42   Log* log;
     43   SessionThreadMap* session_thread_map;
     44   scoped_refptr<URLRequestContextGetter> context_getter;
     45   SyncWebSocketFactory socket_factory;
     46   DeviceManager* device_manager;
     47 };
     48 
     49 // Creates a new session.
     50 void ExecuteNewSession(
     51     const NewSessionParams& bound_params,
     52     const base::DictionaryValue& params,
     53     const std::string& session_id,
     54     const CommandCallback& callback);
     55 
     56 // Quits all sessions.
     57 void ExecuteQuitAll(
     58     const Command& quit_command,
     59     SessionThreadMap* session_thread_map,
     60     const base::DictionaryValue& params,
     61     const std::string& session_id,
     62     const CommandCallback& callback);
     63 
     64 typedef base::Callback<Status(
     65     Session* session,
     66     const base::DictionaryValue&,
     67     scoped_ptr<base::Value>*)> SessionCommand;
     68 
     69 // Executes a given session command, after acquiring access to the appropriate
     70 // session.
     71 void ExecuteSessionCommand(
     72     SessionThreadMap* session_thread_map,
     73     const SessionCommand& command,
     74     bool return_ok_without_session,
     75     const base::DictionaryValue& params,
     76     const std::string& session_id,
     77     const CommandCallback& callback);
     78 
     79 namespace internal {
     80 void CreateSessionOnSessionThreadForTesting(const std::string& id);
     81 }  // namespace internal
     82 
     83 #endif  // CHROME_TEST_CHROMEDRIVER_COMMANDS_H_
     84