Skip to content

Commit

Permalink
Remove unused WaitForAsmCacheReady
Browse files Browse the repository at this point in the history
  • Loading branch information
yukawa committed Jan 27, 2024
1 parent 1636def commit 0c0c02b
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 92 deletions.
18 changes: 0 additions & 18 deletions src/base/system_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -740,24 +740,6 @@ const wchar_t *SystemUtil::GetSystemDir() {
DCHECK(Singleton<SystemDirectoryCache>::get()->succeeded());
return Singleton<SystemDirectoryCache>::get()->system_dir();
}

std::string SystemUtil::GetMSCTFAsmCacheReadyEventName() {
const std::string &session_id = GetSessionIdString();
if (session_id.empty()) {
DLOG(ERROR) << "Failed to retrieve session id";
return "";
}

const std::string &desktop_name = GetInputDesktopName();

if (desktop_name.empty()) {
DLOG(ERROR) << "Failed to retrieve desktop name";
return "";
}

// Compose "Local\MSCTF.AsmCacheReady.<desktop name><session #>".
return ("Local\\MSCTF.AsmCacheReady." + desktop_name + session_id);
}
#endif // _WIN32

// TODO(toshiyuki): move this to the initialization module and calculate
Expand Down
8 changes: 0 additions & 8 deletions src/base/system_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ class SystemUtil {
// You need not to delete the returned pointer.
// This function is thread safe.
static const wchar_t *GetSystemDir();

// Returns "MSCTF.AsmCacheReady.<desktop name><session #>" to work around
// b/5765783.
// Returns an empty string if fails.
// Currently this method is defined in util.h because it depends on some
// utility functions defined in util.cc.
// TODO(yukawa): Move this method to win32/base/*
static std::string GetMSCTFAsmCacheReadyEventName();
#endif // _WIN32

// return string representing os version
Expand Down
1 change: 0 additions & 1 deletion src/win32/base/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ mozc_cc_library(
":msctf_dll",
":tsf_profile",
"//base:logging",
"//base:system_util",
"//base/win32:wide_char",
"@com_microsoft_wil//:wil",
],
Expand Down
44 changes: 0 additions & 44 deletions src/win32/base/imm_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include <vector>

#include "base/logging.h"
#include "base/system_util.h"
#include "base/win32/wide_char.h"
#include "win32/base/input_dll.h"
#include "win32/base/tsf_profile.h"
Expand All @@ -55,15 +54,6 @@

namespace mozc {
namespace win32 {
namespace {

// Timeout value used by a work around against b/5765783. As b/6165722
// this value is determined to be:
// - smaller than the default time-out used in IsHungAppWindow API.
// - similar to the same timeout used by TSF.
constexpr uint32_t kWaitForAsmCacheReadyEventTimeout = 4500; // 4.5 sec.

} // namespace

bool ImeUtil::SetDefault() {
wchar_t clsid[64] = {};
Expand Down Expand Up @@ -114,39 +104,5 @@ bool ImeUtil::SetDefault() {
return true;
}

// Wait for "MSCTF.AsmCacheReady.<desktop name><session #>" event signal to
// work around b/5765783.
bool ImeUtil::WaitForAsmCacheReady(uint32_t timeout_msec) {
const std::wstring event_name =
Utf8ToWide(SystemUtil::GetMSCTFAsmCacheReadyEventName());
if (event_name.empty()) {
LOG(ERROR) << "Failed to compose event name.";
return false;
}
wil::unique_event_nothrow event;
if (!event.try_open(event_name.c_str(), SYNCHRONIZE, false)) {
// Event not found.
// Returns true assuming that we need not to wait anything.
return true;
}
const DWORD result = ::WaitForSingleObject(event.get(), timeout_msec);
switch (result) {
case WAIT_OBJECT_0:
return true;
case WAIT_TIMEOUT:
LOG(ERROR) << "WaitForSingleObject timeout. timeout_msec: "
<< timeout_msec;
return false;
case WAIT_ABANDONED:
LOG(ERROR) << "Event was abandoned";
return false;
default:
LOG(ERROR) << "WaitForSingleObject with unknown error: " << result;
return false;
}
LOG(FATAL) << "Should never reach here.";
return false;
}

} // namespace win32
} // namespace mozc
21 changes: 0 additions & 21 deletions src/win32/base/imm_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,6 @@ class ImeUtil {
// have not tested. If this is true, you cannot freely call SetDefault()
// in some special situations like CustomAction.
static bool SetDefault();

// Looks like the TSF needs to rebuild a certain cache after changing the
// input details. This task usually takes a few hundreds msec. However,
// if we broadcast WM_INPUTLANGCHANGEREQUEST message to all the desktop
// UI threads before the TSF finishes rebuilding its internal cache, all
// the UI threads which receive the WM_INPUTLANGCHANGEREQUEST message start
// waiting for "MSCTF.AsmCacheReady.<desktop name><session #>" event and
// later waiting for an IMM critical section that the former threads own.
// Perhaps TSF's rebuiding process is not resilient enough for a relatively
// lot of threads. As a result, all the desktop UI threads will be blocked
// for about a minute, as reported in b/5765783.
//
// This method waits for
// "Local\MSCTF.AsmCacheReady.<desktop name><session #>"
// event to cope with the above TSF's behavior.
// You can pass INFINITE to |timeout_msec| to wait for the event forever.
// Returns true if the operation is completed successfully.
// Returns true if "MSCTF.AsmCacheReady.<desktop name><session #>" event does
// not exist.
// Otherwise returns false.
static bool WaitForAsmCacheReady(uint32_t timeout_msec);
};

} // namespace win32
Expand Down

0 comments on commit 0c0c02b

Please sign in to comment.