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

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

Issue 11415205: [chromedriver] Implement connecting to devtools and loading a page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years 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/chromedriver.h ('k') | chrome/test/chromedriver/chromedriver.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/chromedriver.cc
diff --git a/chrome/test/chromedriver/chromedriver.cc b/chrome/test/chromedriver/chromedriver.cc
index 9f66847a3a7706515197d722bcaf9105b4b58445..70b57462483ad3a4cc7043f8e5bf971daf4d6095 100644
--- a/chrome/test/chromedriver/chromedriver.cc
+++ b/chrome/test/chromedriver/chromedriver.cc
@@ -6,14 +6,19 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/synchronization/lock.h"
#include "base/values.h"
#include "chrome/test/chromedriver/command_executor.h"
#include "chrome/test/chromedriver/status.h"
namespace {
+// Guards |g_executor_initialized|.
+base::LazyInstance<base::Lock> g_lazy_lock = LAZY_INSTANCE_INITIALIZER;
+bool g_executor_initialized = false;
CommandExecutor* g_command_executor = NULL;
void SetResponse(StatusCode status,
@@ -39,10 +44,19 @@ void SetError(const std::string& error_msg,
void Init(scoped_ptr<CommandExecutor> executor) {
g_command_executor = executor.release();
+ // We do not call CommandExecutor::Init here because you can't do some things
+ // (e.g., creating threads) during DLL loading on Windows.
}
void ExecuteCommand(const std::string& command, std::string* response) {
CHECK(g_command_executor);
+ {
+ base::AutoLock(g_lazy_lock.Get());
+ if (!g_executor_initialized) {
+ g_command_executor->Init();
+ g_executor_initialized = true;
+ }
+ }
std::string error_msg;
scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError(
command, 0, NULL, &error_msg));
« no previous file with comments | « chrome/test/chromedriver/chromedriver.h ('k') | chrome/test/chromedriver/chromedriver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698