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

Unified Diff: chrome/test/chromedriver/session_commands.cc

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
« no previous file with comments | « chrome/test/chromedriver/session_commands.h ('k') | chrome/test/chromedriver/session_commands_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/session_commands.cc
diff --git a/chrome/test/chromedriver/session_commands.cc b/chrome/test/chromedriver/session_commands.cc
index 45c6f54b78e5bf21b4dc1ba14d82666ed3bd679a..23f362baf49f19f672b1d358cb5901b65631aa6b 100644
--- a/chrome/test/chromedriver/session_commands.cc
+++ b/chrome/test/chromedriver/session_commands.cc
@@ -23,7 +23,6 @@
#include "chrome/test/chromedriver/chrome/web_view.h"
#include "chrome/test/chromedriver/logging.h"
#include "chrome/test/chromedriver/session.h"
-#include "chrome/test/chromedriver/session_map.h"
#include "chrome/test/chromedriver/util.h"
namespace {
@@ -43,53 +42,22 @@ bool WindowHandleToWebViewId(const std::string& window_handle,
return true;
}
-void ExecuteOnSessionThread(
- const SessionCommand& command,
- Session* session,
- const base::DictionaryValue* params,
- scoped_ptr<base::Value>* value,
- Status* status,
- base::WaitableEvent* event) {
- *status = command.Run(session, *params, value);
- event->Signal();
-}
-
} // namespace
-Status ExecuteSessionCommand(
- SessionMap* session_map,
- const SessionCommand& command,
+Status ExecuteQuit(
+ bool allow_detach,
+ Session* session,
const base::DictionaryValue& params,
- const std::string& session_id,
- scoped_ptr<base::Value>* out_value,
- std::string* out_session_id) {
- *out_session_id = session_id;
- scoped_refptr<SessionAccessor> session_accessor;
- if (!session_map->Get(session_id, &session_accessor))
- return Status(kNoSuchSession, session_id);
- scoped_ptr<base::AutoLock> session_lock;
- Session* session = session_accessor->Access(&session_lock);
- if (!session)
- return Status(kNoSuchSession, session_id);
-
- Status status(kUnknownError);
- base::WaitableEvent event(false, false);
- session->thread.message_loop_proxy()->PostTask(
- FROM_HERE,
- base::Bind(&ExecuteOnSessionThread, command, session,
- &params, out_value, &status, &event));
- event.Wait();
- if (status.IsError() && session->chrome)
- status.AddDetails("Session info: chrome=" + session->chrome->GetVersion());
- // Delete the session, because concurrent requests might hold a reference to
- // the SessionAccessor already.
- if (!session_map->Has(session_id))
- session_accessor->DeleteSession();
- return status;
+ scoped_ptr<base::Value>* value) {
+ if (allow_detach && session->detach) {
+ return Status(kOk);
+ } else {
+ session->quit = true;
+ return session->chrome->Quit();
+ }
}
Status ExecuteGetSessionCapabilities(
- SessionMap* session_map,
Session* session,
const base::DictionaryValue& params,
scoped_ptr<base::Value>* value) {
@@ -111,7 +79,6 @@ Status ExecuteGetCurrentWindowHandle(
}
Status ExecuteClose(
- SessionMap* session_map,
Session* session,
const base::DictionaryValue& params,
scoped_ptr<base::Value>* value) {
@@ -135,7 +102,7 @@ Status ExecuteClose(
if ((status.code() == kChromeNotReachable && is_last_web_view) ||
(status.IsOk() && web_view_ids.empty())) {
// If no window is open, close is the equivalent of calling "quit".
- CHECK(session_map->Remove(session->id));
+ session->quit = true;
return session->chrome->Quit();
}
« no previous file with comments | « chrome/test/chromedriver/session_commands.h ('k') | chrome/test/chromedriver/session_commands_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698