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

Unified Diff: chrome/test/chromedriver/server/http_handler.h

Issue 19616008: [chromedriver] Allow commands to be async. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/server/http_handler.h
diff --git a/chrome/test/chromedriver/server/http_handler.h b/chrome/test/chromedriver/server/http_handler.h
index d40fab8dc5f43d76d78400f801c8f6c9849a8dc2..3ad42a12b5bce10e0e889ca49274e1977de5bff1 100644
--- a/chrome/test/chromedriver/server/http_handler.h
+++ b/chrome/test/chromedriver/server/http_handler.h
@@ -10,17 +10,21 @@
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/threading/thread.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
#include "chrome/test/chromedriver/command.h"
+#include "chrome/test/chromedriver/commands.h"
#include "chrome/test/chromedriver/element_commands.h"
#include "chrome/test/chromedriver/net/sync_websocket_factory.h"
#include "chrome/test/chromedriver/session_commands.h"
-#include "chrome/test/chromedriver/session_map.h"
+#include "chrome/test/chromedriver/session_thread_map.h"
#include "chrome/test/chromedriver/window_commands.h"
namespace base {
class DictionaryValue;
+class SingleThreadTaskRunner;
}
namespace net {
@@ -50,13 +54,18 @@ struct CommandMapping {
Command command;
};
+typedef base::Callback<void(scoped_ptr<HttpResponse>)> HttpResponseSenderFunc;
+
class HttpHandler {
public:
HttpHandler(Log* log, const std::string& url_base);
+ HttpHandler(const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
+ Log* log,
+ const std::string& url_base);
~HttpHandler();
void Handle(const net::HttpServerRequestInfo& request,
- HttpResponse* response);
+ const HttpResponseSenderFunc& send_response_func);
bool ShouldShutdown(const net::HttpServerRequestInfo& request);
private:
@@ -70,23 +79,33 @@ class HttpHandler {
Command WrapToCommand(const SessionCommand& session_command);
Command WrapToCommand(const WindowCommand& window_command);
Command WrapToCommand(const ElementCommand& element_command);
- void HandleInternal(const net::HttpServerRequestInfo& request,
- HttpResponse* response);
- bool HandleWebDriverCommand(
- const net::HttpServerRequestInfo& request,
+ void HandleCommand(const net::HttpServerRequestInfo& request,
+ const std::string& trimmed_path,
+ const HttpResponseSenderFunc& send_response_func);
+ void PrepareResponse(const std::string& trimmed_path,
+ const HttpResponseSenderFunc& send_response_func,
+ const Status& status,
+ scoped_ptr<base::Value> value,
+ const std::string& session_id);
+ scoped_ptr<HttpResponse> PrepareResponseHelper(
const std::string& trimmed_path,
- HttpResponse* response);
+ const Status& status,
+ scoped_ptr<base::Value> value,
+ const std::string& session_id);
+ base::ThreadChecker thread_checker_;
Log* log_;
- base::Thread io_thread_;
std::string url_base_;
+ bool received_shutdown_;
scoped_refptr<URLRequestContextGetter> context_getter_;
SyncWebSocketFactory socket_factory_;
- SessionMap session_map_;
+ SessionThreadMap session_thread_map_;
scoped_ptr<CommandMap> command_map_;
scoped_ptr<Adb> adb_;
scoped_ptr<DeviceManager> device_manager_;
+ base::WeakPtrFactory<HttpHandler> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(HttpHandler);
};
« no previous file with comments | « chrome/test/chromedriver/server/chromedriver_server.cc ('k') | chrome/test/chromedriver/server/http_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698