Skip to content

Commit

Permalink
[iedriver] Formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Nov 3, 2021
1 parent a33e739 commit 2250ab2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
15 changes: 8 additions & 7 deletions cpp/iedriver/BrowserFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,18 @@ bool BrowserFactory::DirectoryExists(std::wstring& dir_name) {

bool BrowserFactory::CreateUniqueTempDir(std::wstring &temp_dir) {
// get temporary folder for the current user
wchar_t temp[128];
::GetTempPath(128, temp);
std::wstring wtemp = temp;
if (!DirectoryExists(wtemp)) {
wchar_t temp_path_array[128];
::GetTempPath(128, temp_path_array);
std::wstring temp_path = temp_path_array;
if (!DirectoryExists(temp_path)) {
return false;
}

// create a IEDriver temporary folder inside the user level temporary folder
bool temp_dir_created = false;
for (int i=0; i<10; i++) {
std::wstring output = wtemp + L"IEDriver-" + StringUtilities::CreateGuid();
for (int i = 0; i < 10; i++) {
std::wstring output =
temp_path + L"IEDriver-" + StringUtilities::CreateGuid();
if (DirectoryExists(output)) {
continue;
}
Expand Down Expand Up @@ -1293,7 +1294,7 @@ bool BrowserFactory::ProtectedModeSettingsAreValid() {
bool settings_are_valid = true;
LOG(DEBUG) << "Detected IE version: " << this->ie_major_version_
<< ", Windows version supports Protected Mode: "
<< IsWindowsVistaOrGreater() ? "true" : "false";
<< IsWindowsVistaOrGreater() ? "true" : "false";
// Only need to check Protected Mode settings on IE 7 or higher
// and on Windows Vista or higher. Otherwise, Protected Mode
// doesn't come into play, and are valid.
Expand Down
17 changes: 11 additions & 6 deletions cpp/iedriver/IECommandExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ LRESULT IECommandExecutor::OnBrowserQuit(UINT uMsg,
LPCSTR str = reinterpret_cast<LPCSTR>(lParam);
std::string browser_id(str);
delete[] str;
BrowserMap::iterator found_iterator = this->managed_browsers_.find(browser_id);
BrowserMap::iterator found_iterator =
this->managed_browsers_.find(browser_id);

if (found_iterator != this->managed_browsers_.end()) {
this->managed_browsers_.erase(browser_id);
if (this->managed_browsers_.size() == 0) {
Expand All @@ -470,16 +472,19 @@ LRESULT IECommandExecutor::OnBrowserQuit(UINT uMsg,
// Delete IEDriver temporary folder when IEDriver drvies Edge in IEMode.
// Note that the this->factory_ object might have been deleted.
if (this->edge_temp_dir_ != L"") {
for (int i=0;i<100;i++) {
::Sleep(100); // wait for the Edge browser completing read/write work
for (int i = 0; i < 100; i++) {
// wait for the Edge browser completing read/write work
// the delete usually completes in 1 retries
::Sleep(100);
if (BrowserFactory::DeleteDirectory(edge_temp_dir_)) {
// directory delete failed when some files/folders are locked
LOG(TRACE) << "Failed to delete Edge temporary user data directory " << LOGWSTRING(edge_temp_dir_)
<< ", retrying " << i+1 << "...";
LOG(TRACE) << "Failed to delete Edge temporary user data directory "
<< LOGWSTRING(edge_temp_dir_) << ", retrying "
<< i + 1 << "...";
} else {
// the temporary folder has been deleted
LOG(TRACE) << "Deleted Edge temporary user data directory " << LOGWSTRING(edge_temp_dir_) << ".";
LOG(TRACE) << "Deleted Edge temporary user data directory "
<< LOGWSTRING(edge_temp_dir_) << ".";
break;
}
}
Expand Down

0 comments on commit 2250ab2

Please sign in to comment.